主题:python 进程间通信
代码很简单,所以就没注释了:}
[python]
"""
采用windows事件和共享内存实现进程间通信。
"""
#reader
import win32event as w32e
import win32api as wapi
import mmapfile as mmf
hEvent = w32e.CreateEvent(None , 0 , 0 , "Global\\JmdebuggerEvent")
#system_info=wapi.GetSystemInfo()
#page_size=system_info[1]
pyMm = mmf.mmapfile(None , "JmdebuggerMem" ,1024 )
if hEvent != None and pyMm != None :
w32e.WaitForSingleObject(hEvent , -1)
buf = pyMm.read(16)
print buf
wapi.CloseHandle(hEvent)
pyMm.close()
[python] view plaincopy
#writer
import win32event as w32e
import mmapfile as mmf
hEvent = w32e.OpenEvent(w32e.EVENT_ALL_ACCESS , 0 ,"Global\\JmdebuggerEvent")
pyMm = mmf.mmapfile(None , "JmdebuggerMem" ,1024)
if hEvent != None and pyMm != None:
w32e.SetEvent(hEvent)
pyMm.write("hello world!");
以上就是Python进程间通信
[python]
"""
采用windows事件和共享内存实现进程间通信。
"""
#reader
import win32event as w32e
import win32api as wapi
import mmapfile as mmf
hEvent = w32e.CreateEvent(None , 0 , 0 , "Global\\JmdebuggerEvent")
#system_info=wapi.GetSystemInfo()
#page_size=system_info[1]
pyMm = mmf.mmapfile(None , "JmdebuggerMem" ,1024 )
if hEvent != None and pyMm != None :
w32e.WaitForSingleObject(hEvent , -1)
buf = pyMm.read(16)
print buf
wapi.CloseHandle(hEvent)
pyMm.close()
[python] view plaincopy
#writer
import win32event as w32e
import mmapfile as mmf
hEvent = w32e.OpenEvent(w32e.EVENT_ALL_ACCESS , 0 ,"Global\\JmdebuggerEvent")
pyMm = mmf.mmapfile(None , "JmdebuggerMem" ,1024)
if hEvent != None and pyMm != None:
w32e.SetEvent(hEvent)
pyMm.write("hello world!");
以上就是Python进程间通信