Skip to content
Snippets Groups Projects
Commit 59a7b9f6 authored by gpotter2's avatar gpotter2
Browse files

Replaced thread by threading

parent b0266116
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
## Copyright (C) Philippe Biondi <phil@secdev.org> ## Copyright (C) Philippe Biondi <phil@secdev.org>
## This program is published under a GPLv2 license ## This program is published under a GPLv2 license
import os, thread import os
import subprocess import subprocess
import itertools import itertools
import collections import collections
import time import time
import Queue import Queue
from threading import Lock, Thread
from scapy.automaton import Message, select_objects from scapy.automaton import Message, select_objects
from scapy.consts import WINDOWS from scapy.consts import WINDOWS
...@@ -43,8 +44,8 @@ class PipeEngine: ...@@ -43,8 +44,8 @@ class PipeEngine:
self.active_drains = set() self.active_drains = set()
self.active_sinks = set() self.active_sinks = set()
self._add_pipes(*pipes) self._add_pipes(*pipes)
self.thread_lock = thread.allocate_lock() self.thread_lock = Lock()
self.command_lock = thread.allocate_lock() self.command_lock = Lock()
self.__fd_queue = [] self.__fd_queue = []
self.__fdr,self.__fdw = os.pipe() self.__fdr,self.__fdw = os.pipe()
self.threadid = None self.threadid = None
...@@ -149,7 +150,9 @@ class PipeEngine: ...@@ -149,7 +150,9 @@ class PipeEngine:
def start(self): def start(self):
if self.thread_lock.acquire(0): if self.thread_lock.acquire(0):
self.threadid = thread.start_new_thread(self.run,()) _t = Thread(target=self.run)
_t.start()
self.threadid = _t.ident
else: else:
warning("Pipe engine already running") warning("Pipe engine already running")
def wait_and_stop(self): def wait_and_stop(self):
...@@ -383,7 +386,7 @@ class ThreadGenSource(AutoSource): ...@@ -383,7 +386,7 @@ class ThreadGenSource(AutoSource):
pass pass
def start(self): def start(self):
self.RUN = True self.RUN = True
thread.start_new_thread(self.generate,()) Thread(target=self.generate).start()
def stop(self): def stop(self):
self.RUN = False self.RUN = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment