On Wed, Aug 29, 2012 at 10:18:59AM -0700, Ben Pfaff wrote:
> On Tue, Aug 28, 2012 at 05:37:06PM +0900, Isaku Yamahata wrote:
> > On Mon, Aug 27, 2012 at 10:10:13PM -0700, Ben Pfaff wrote:
> > > On Wed, Aug 22, 2012 at 07:07:05PM +0900, Isaku Yamahata wrote:
> > > > eventlet/gevent doesn't work well with select.poll because it blocks.
> > > > So ovsdb python binding can't be used with eventlet/gevent.
> > > > So monkey patch to select.poll with a function that emulate select.poll
> > > > with select.select.
> > > > 
> > > > Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp>
> > > 
> > > What's going to use this?
> > 
> > My motivation is to use ovsdb python binding in openstack quantum which
> > uses eventlet (I have Ryu plugin in mind, but I think other plugin can
> > benefit) and in Ryu which uses gevent.
> 
> Hmm.  Depending on the way that the code is structured, you might be
> able to just pass an object of a different class that simply implements
> fd_wait, timer_wait, timer_wait_until, and immediate_wake differently.
> Did you consider that solution?  Or we could define an abstract
> superclass for Poller with the current Poller as the default concrete
> definition.  I'd be open to that, if it would help.

Then I'd like to introduce an abstract superclass.
How about this?

abstract
class _SelectPollBase(object):
    __metaclass__ = ABCMeta
    @abstractmethod
    def register(self, fd, events):
        pass
    @abstractmethod
    def poll(self, timeout):
        pass

class _SelectPoll(_SelectPollBase):
    def register(self, fd, events):
        select.poll(fd, events)

    def poll(self, timeout):
        select.pol(timetout)

class _SelectSelect(_SelectPollBase):
    ....

SelectPoll = _SelectPoll
# if eventlet/gevent: SelectPoll = _SelectSelect

class Poller(object)
    def __init__(self, select_poll=SelectPoll):
        self.select_poll = select_poll
...
  

I should have state the issue clearly. The issues is NOT how to use
*_wait. The issues is that select.poll with eventlet/gevent blocks
python interpreter as a whole due to the eventlet/gevent implementation
details. So the all execution of green-threads are blocked instead of
switching to runnable thread.
-- 
yamahata
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to