ffalcinelli / pydivert

A Python binding for WinDivert driver
GNU Lesser General Public License v3.0
200 stars 36 forks source link

multiprocessing and pydivert #39

Open BoerTheun opened 5 years ago

BoerTheun commented 5 years ago

I am not able to start multiple windivert handles with pydivert if it is not in the main program. I get a runtime error, RuntimeError: WinDivert handle is not open, even if I only start one process.

def inboundFunc():
    w = pydivert.WinDivert("inbound")

    while 1:
        packet = w.recv()
        #dosomething
        w.send(packet)

def outboundFunc():
    w = pydivert.WinDivert("outbound")

    while 1:
        packet = w.recv()
        #dosomething
        w.send(packet)

if __name__ == '__main__':

    p1 = Process(name='inboundProcess', target=inboundFunc)
    p2 = Process(name='outboundProcess', target=outboundFunc)

    p1.start()
    p2.start()
ly3too commented 5 years ago

Try call w.open() before while