producer and consumer models
Project description
- long_desciption
from Producer_Consumer.QueueTool import QueueProducer
from Producer_Consumer.QueueTool import QueueConsumer
from Producer_Consumer.QueueTool import QueueConsumerProcess
import multiprocessing
import json
def test_func(data):
“””test function”””
return json.dumps({“result”: data})
def test():
“””test”””
process_list = []
producer = QueueProducer()
lock = multiprocessing.Lock()
for i in range(4):
p = QueueConsumerProcess(target=test_func, input_queue=producer.queue, filename=”123.json”,
name=”process%d” % i, lock=lock)
p.start()
process_list.append(p)
for i in range(1000000):
producer.produce(str(i))
print(“produce done”)
for p in process_list:
p.stop()
p.join()
if __name__ == ‘__main__’:
test()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file Producer_Consumer-19.9.tar.gz
.
File metadata
- Download URL: Producer_Consumer-19.9.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/0.9.8 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/2.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebc19386197f1466a5cfc1626ae32a61e6c9c2cb43ce725561aebf5170aae683 |
|
MD5 | ba603db1f1ca14d35981ffb3bd8b81d1 |
|
BLAKE2b-256 | 33ff8d76a0f671b1d454c65ea770f1607f3a3874d79d9bb5fb7224791342b1ef |