Re: [ctypes-users] callbacks and threading
Brought to you by:
theller
From: Diez B. R. <de...@we...> - 2016-08-28 15:28:40
|
It is not possible for ctypes (or anything else, for that matter) to force a running thread to execute arbitrary other code, and the just jump back to execution. I see two options that need investigation: - currentThread is for whatever reason confused. You could try that out by making your callback stall for several seconds (time.sleep), and observe if the mainloop is still running. - the mainloop you describe is an actual eventloop, in which case the design of your application needs to be altered. For this we would need to see more code. So - which is it? Diez > On 19 Aug 2016, at 23:44, KP <pat...@gm...> wrote: > > I have a python client with ctypes wrappers to call in to a DLL that in turn talks to a server process. One of the features is to register a callback on an event. I am able to successfully register callbacks, and they do get called on events...so all is working well there. > > However, it seems the callbacks are always executed in the "main" thread...even when I know there are other commands running in the main thread. > > I'm not entirely sure how this happens/or is possible. The main thread is running a loop, but the callback also reports being in the main thread (by printing threading.currentThread()). Is this something ctypes has control over that I can tweak? > > I need it to be in a different thread so that any CTRL-C will _not_ end up in that thread, and will instead impact the main thread...er, well, what I am thinking of as the main thread (not the callback). > > Any ideas? Thanks, > Kevin > ------------------------------------------------------------------------------ > _______________________________________________ > ctypes-users mailing list > cty...@li... > https://lists.sourceforge.net/lists/listinfo/ctypes-users |