What Is Equivalent To Sigusr1-2 Signals In Windows Using Python?
Solution 1:
It really depends on what you're looking for- whether you want control over messages, non-blocking messages, or the ability to capture external signals like you normally would with the signal
module.
Since you want to send "notifications between two python processes" I recommend the multiprocessing.connection
module's Client and Listener classes for a very easy message-oriented pair of connection objects:
http://docs.python.org/2/library/multiprocessing.html#module-multiprocessing.connection
In Process A:
listener = Listener(('localhost', 9000)) # local TCP connections on port 9000
remote_conn = listener.accept()
listener.close()
print remote_conn.recv()
# prints 'a pickle-able object'print remote_conn.recv()
# prints "['another', 'pickle-able', 'object']"
In Process B:
client = Client(('localhost', 9000))
client.send('a pickle-able object')
client.send(['another', 'pickle-able', 'object'])
The fact that these classes are built-in makes me happy- no installations required! Just be careful to follow the docs guidelines about security and un-pickling data.
Solution 2:
There is no SIGUSR1
nor SIGUSR2
in Windows platform. You can confirm by doing this:
C:\>python
Python 3.7.0 (default, Jun 282018, 08:04:48) [MSC v.191264 bit (AMD64)] :: Anaconda custom (64-bit) on win32
Type"help", "copyright", "credits"or"license"for more information.
>>> import signal
>>> dir(signal)
['CTRL_BREAK_EVENT', 'CTRL_C_EVENT', 'Handlers', 'NSIG', 'SIGABRT', 'SIGBREAK', 'SIGFPE', 'SIGILL', 'SIGINT', 'SIGSEGV', 'SIGTERM', 'SIG_DFL', 'SIG_IGN', 'Signals', '_IntEnum', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_enum_to_int', '_int_to_enum', '_signal', 'default_int_handler', 'getsignal', 'set_wakeup_fd', 'signal']
Here 1 is the official documentation from Windows.
Solution 3:
Try zeromq for interprocess communication via sockets.
Post a Comment for "What Is Equivalent To Sigusr1-2 Signals In Windows Using Python?"