-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.py
More file actions
72 lines (59 loc) · 1.62 KB
/
testing.py
File metadata and controls
72 lines (59 loc) · 1.62 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import logging
import threading
import multiprocessing
from multiprocessing import Process, Queue
import copy
import collections
from pdb import set_trace as bp
import time
class config(object):
def __init__(self, arg):
self.task_queue = Queue()
self.cond = multiprocessing.Condition()
class Task(object):
def __init__(self, arg):
print("Init function in task")
self.config = arg
def task_scheduler(self, name):
print("In tas function function in task")
global c, num
bp()
print(name)
logging.info ("Thread: Frist name:" + name)
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
logging.info("Thread logg")
time.sleep(2)
i = 0
while not c.task_queue.empty():
with self.config.cond:
i = i+1
if i == 9:
self.config.cond.wait()
print("recevid")
name = "Kumar"
print(c.task_queue.get())
print(name)
logging.info ("Thread: Last name:"+ name)
if __name__=="__main__":
num = 10
c = config(1)
logging.basicConfig(filename='events_log.log',filemode='w',format='%(levelname)s:%(asctime)s:%(message)s', datefmt='%m/%d/%Y %I:%M:%S %p',level=logging.INFO)
logging.debug('This message should appear on the console')
logging.info('So should this')
logging.warning('And this, too')
name = "Veer"
print(name)
t = Task(c)
x = threading.Thread(target=t.task_scheduler, args=(name,))
logging.warning('NEW WARNING And this, too')
x.start()
for i in range(10):
if i == 9:
time.sleep(7)
print("releasing")
with c.cond:
c.cond.notify_all()
c.task_queue.put(i)
logging.info("Last message")
x.join()
logging.info ("Final name:" + name)