Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
czos-dpend
routersploit
Commits
8c7ece59
Commit
8c7ece59
authored
Jul 31, 2016
by
fwkz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding dedicated sub-classed thread classes.
parent
6c0ce514
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
threads.py
routersploit/threads.py
+51
-0
No files found.
routersploit/threads.py
0 → 100644
View file @
8c7ece59
from
__future__
import
print_function
from
__future__
import
absolute_import
import
threading
from
weakref
import
WeakKeyDictionary
try
:
import
queue
except
ImportError
:
import
Queue
as
queue
data_queue
=
queue
.
Queue
()
printer_queue
=
queue
.
Queue
()
class
DataProducerThread
(
threading
.
Thread
):
def
__init__
(
self
,
data
):
super
(
DataProducerThread
,
self
)
.
__init__
(
name
=
self
.
__class__
.
__name__
)
self
.
data
=
data
def
run
(
self
):
for
record
in
self
.
data
:
data_queue
.
put
(
record
)
class
WorkerThread
(
threading
.
Thread
):
def
__init__
(
self
):
super
(
WorkerThread
,
self
)
.
__init__
()
def
run
(
self
):
while
not
data_queue
.
empty
():
record
=
data_queue
.
get
()
self
.
target
(
record
)
data_queue
.
task_done
()
def
target
(
self
,
record
):
pass
class
PrinterThread
(
threading
.
Thread
):
def
__init__
(
self
):
super
(
PrinterThread
,
self
)
.
__init__
()
self
.
daemon
=
True
self
.
std_out
=
WeakKeyDictionary
()
def
run
(
self
):
while
True
:
content
,
sep
,
end
,
file_
=
printer_queue
.
get
()
print
(
*
content
,
sep
=
sep
,
end
=
end
,
file
=
file_
)
printer_queue
.
task_done
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment