Any way to stop streaming subscription early? #1108
-
I'm using exchangelib to create a Windows service that monitors a mailbox using a streaming subscription. Everything works great, except that because the streaming subscription blocks for the duration of the connection_timeout, the service will not stop when requested until the connection_timeout expires. Is there any way that I can force the connection to end early, maybe based on a flag I set or something like that? I'm doing something like this:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I don't know how this sort of thing works in Windows. On Unix you would send the service process a signal, SIGHUP for example, and in the code for the service you register a signal handler that exits the process. You could also run your for loop in a thread and have the outer process detect when to exit. Anyway, this is a general problem and not something specific to exchangelib. |
Beta Was this translation helpful? Give feedback.
-
Just in case anyone else stumbles across this with the same question... I just ran my loop in a thread and that worked great to solve this problem. Thanks for the suggestion! |
Beta Was this translation helpful? Give feedback.
I don't know how this sort of thing works in Windows. On Unix you would send the service process a signal, SIGHUP for example, and in the code for the service you register a signal handler that exits the process.
You could also run your for loop in a thread and have the outer process detect when to exit.
Anyway, this is a general problem and not something specific to exchangelib.