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.

Filename, size & hash SHA256 hash help File type Python version Upload date
Producer_Consumer-19.7.tar.gz (3.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page