【发布时间】:2011-06-01 11:13:42
【问题描述】:
我正在使用 twsited 的 INotify 来监控 /dev 目录以监控正在添加的新串行设备。我目前使用的代码与下面类似。
notifier = INotify()
notifier.watch(FilePath("/dev"), IN_CREATE, callbacks=[self.created])
notifier.startReading()
def created(self, ignored, path, mask):
...
blocking code
...
我现在遇到的问题是当“created”被调用时,它阻塞了我的反应器,所以其他网络会话(我有与同一个反应器关联的 TCP 和 UDP 连接)必须等待“created” ' 方法来完成。
有谁知道如何让“created”方法在后台运行,这样它就不会阻塞我的反应器?
谢谢,
西蒙
【问题讨论】:
标签: python twisted blocking inotify