python 进程间通信
程序员文章站
2022-06-20 23:46:39
代码很简单,所以就没注释了:}
[python]
"""
采用windows事件和共享内存实现进程间通信。
 ...
代码很简单,所以就没注释了:}
[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]
"""
采用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中的闭包实例详解
下一篇: php 发送带附件邮件示例