-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathargs_values.py
More file actions
56 lines (41 loc) · 1.27 KB
/
args_values.py
File metadata and controls
56 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python
## This is not very trivial to access the values of
## args and kwargs from a subclass as their values are
## being saved in private variables.
import threading
import logging
import time
logging.basicConfig(level=logging.DEBUG,
format='(%(threadName)-10s) %(message)s',
)
class ThreadWithArgs(threading.Thread):
def __init__(self,
group=None,
target=None,
name=None,
args=(),
kwargs=None,
verbose=None
):
threading.Thread.__init__(self,
group=group,
target=target,
name=name,
verbose=verbose
)
self.args = args
self.kwargs = kwargs
return
def run(self):
logging.debug('This thread is running with %s and %s', self.args, self.kwargs)
return
def Main():
for x in range(5):
myThread = ThreadWithArgs(
args=(x,),
kwargs={'Country':'USA', 'Zip':'12345'}
)
myThread.start()
time.sleep(1)
if __name__ == "__main__":
Main()