Hi,

I use libevent through the libevent-python wrapper.
If it is not the relevant mailing list to ask, please point me to the right
place ;)

I wanted to write an event loop, running in its own thread, while another
thread can do something else.
Whatever I've tried, the first call to 'dispatch' block all the others
threads (from what I understand).
I wrote something like:

def evhello(obj, name):
   # dummy callback: print hello every second
   print "hello", name
   if obj:
       obj.addToLoop(timeout=1)

def evstart(name, next=None):
   evB = libevent.EventBase() # new base for each thread
   event = libevent.createTimer(lambda fd, events, obj: evhello(obj, name))
   event.setEventBase(evB)
   event.addToLoop(timeout=1)
   evB.dispatch()

t0 = threading.Thread(target=evhello, args=(None, 'toto'))
t1 = threading.Thread(target=evstart, args=('toto',))
t2 = threading.Thread(target=evstart, args=('titi',))

t0.start()
time.sleep(3)
# t0 is effectively running ...

t1.start()
time.sleep(3)
# t1 event loop is running ... but t0 STOPed!!!

t2.start()
# ... never reach


Anybody has a clue on the problem?
Is it normal behaviour?
Am I doing something wrong?
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to