0% found this document useful (0 votes)
6 views2 pages

Main - Put: Import From Import From Import From Import

thgjhfghfgdddd

Uploaded by

Arun Mmohanty
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Main - Put: Import From Import From Import From Import

thgjhfghfgdddd

Uploaded by

Arun Mmohanty
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

In [18]:

import threading
from threading import *
from time import *
from queue import *

q=Queue(maxsize=3)

def main_put(q):
name=[Link]().name
f= open('[Link]').read()
f=[Link]()
for i in f:
print(f"thread: {name} start put into queue, Q Current size {[Link]()} at the t
[Link](i)
print(f"thread: {name} successfully put into queue, Q Current size {[Link]()} a
[Link]()

def main_get(q):
name=[Link]().name
while True:
print(f"start get item {name} from queue, Q Current size {[Link]()} at the tim
host=[Link]()
sleep(2)
print(f"{name} finish process {host} from queue, Q Current size {[Link]()} at t
q.task_done()

if __name__ == '__main__':
name=[Link]().name
print(f"start the program {name}")
t_num=5
for i in range(t_num):
t=Thread(target=main_get, args=(q,))
[Link]()

t1=Thread(target=main_put, name='main_put_thread', args=(q,)) ###one thread


[Link]()
[Link]()

start the program MainThread


start get item Thread-82 from queue, Q Current size 0 at the time Wed Jul
8 16:40:52 2020

start get item Thread-83 from queue, Q Current size 0 at the time Wed Jul
8 16:40:52 2020

start get item Thread-84 from queue, Q Current size 0 at the time Wed Jul
8 16:40:52 2020

start get item Thread-85 from queue, Q Current size 0 at the time Wed Jul
8 16:40:52 2020

start get item Thread-86 from queue, Q Current size 0 at the time Wed Jul
8 16:40:52 2020

thread: main_put_thread start put into queue, Q Current size 0 at the time
Wed Jul 8 16:40:52 2020

thread: main_put_thread successfully put into queue, Q Current size 1 at t


he time Wed Jul 8 16:40:52 2020

thread: main_put_thread start put into queue, Q Current size 0 at the time
Wed Jul 8 16:40:52 2020

thread: main_put_thread successfully put into queue, Q Current size 1 at t


he time Wed Jul 8 16:40:52 2020

thread: main_put_thread start put into queue, Q Current size 1 at the time
Wed Jul 8 16:40:52 2020

thread: main_put_thread successfully put into queue, Q Current size 2 at t


he time Wed Jul 8 16:40:52 2020

thread: main_put_thread start put into queue, Q Current size 0 at the time
Wed Jul 8 16:40:52 2020

thread: main_put_thread successfully put into queue, Q Current size 1 at t


he time Wed Jul 8 16:40:52 2020

thread: main_put_thread start put into queue, Q Current size 1 at the time
Wed Jul 8 16:40:52 2020

thread: main_put_thread successfully put into queue, Q Current size 1 at t


he time Wed Jul 8 16:40:52 2020

thread: main_put_thread start put into queue, Q Current size 0 at the time
Wed Jul 8 16:40:52 2020

thread: main_put_thread successfully put into queue, Q Current size 1 at t


he time Wed Jul 8 16:40:52 2020

thread: main_put_thread start put into queue, Q Current size 1 at the time
Wed Jul 8 16:40:52 2020

thread: main_put_thread successfully put into queue, Q Current size 2 at t


he time Wed Jul 8 16:40:52 2020

thread: main_put_thread start put into queue, Q Current size 2 at the time
Wed Jul 8 16:40:52 2020

thread: main_put_thread successfully put into queue, Q Current size 3 at t


he time Wed Jul 8 16:40:52 2020

thread: main_put_thread start put into queue, Q Current size 3 at the time
Wed Jul 8 16:40:52 2020

Thread-82 finish process vm1 from queue, Q Current size 3 at the time Wed
Jul 8 16:40:54 2020

start get item Thread-82 from queue, Q Current size 3 at the time Wed Jul
8 16:40:54 2020

thread: main_put_thread successfully put into queue, Q Current size 3 at t


he time Wed Jul 8 16:40:54 2020
Thread-83 finish process vm2 from queue, Q Current size 3 at the time Wed
Jul 8 16:40:54 2020

thread: main_put_thread start put into queue, Q Current size 3 at the time
Wed Jul 8 16:40:54 2020

You might also like