Skip to main content

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

Producer_Consumer-19.9.tar.gz (3.4 kB view details)

Uploaded Source

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

Hashes for Producer_Consumer-19.9.tar.gz
Algorithm Hash digest
SHA256 ebc19386197f1466a5cfc1626ae32a61e6c9c2cb43ce725561aebf5170aae683
MD5 ba603db1f1ca14d35981ffb3bd8b81d1
BLAKE2b-256 33ff8d76a0f671b1d454c65ea770f1607f3a3874d79d9bb5fb7224791342b1ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page