python.net - Does Python for .NET event handler execute in a worker thread -
i have python .net (2.7) script subscribes event defined in .net assembly. when event fires , python-based event handler called, handler executing in python's main thread or in worker thread?
... def myeventhandler(source, args): print 'received message: ' + args.message ... dotnetobject.someevent += myeventhandler ...
i figured must worker thread when put line of code in handler:
print threading._active
it reported main thread:
{8920: <_mainthread(mainthread, started 8920)>}
how can tell thread given line of python executing in?
update: okay, found threading.current_thread(). outside of handler returns:
<_mainthread(mainthread, started 7064)>
while inside handler returns
<_dummythread(dummy-1, started daemon 7916)>
so "dummythread" worker thread? why didn't show in threading._active?
thanks.
dummythreads worker threads , show in call:
threading.enumerate()
so, yes, event handler executing in worker thread.
Comments
Post a Comment