Skip to main content

Multithreating producent-consumer solution

Project description

queuing

Multithreating producent-consumer solution

Example

import queuing
import time
import logging

logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(levelname)5s] %(name)s %(message)s')


@queuing.consumer(instances=5)
def m1(no):
    time.sleep(1)
    print("m1 {}".format(no))
    queuing.broker.send('m2', {
        'no': no,
        'sqno': no * no,
    })
    [queuing.broker.send('m3', {
        'no': no,
    }) for i in range(0, 10)]


@queuing.consumer(instances=2)
def m2(no, sqno):
    time.sleep(2)
    print("m2 {} {}".format(no, sqno))


@queuing.consumer(instances=1)
def m3(no):
    print("m3 {}".format(no))


if __name__ == '__main__':
    for i in range(0, 10):
        queuing.broker.send('m1', {
            'no': i
        })

    queuing.broker.loop()

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

queuing-0.3.0.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

queuing-0.3.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file queuing-0.3.0.tar.gz.

File metadata

  • Download URL: queuing-0.3.0.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for queuing-0.3.0.tar.gz
Algorithm Hash digest
SHA256 848a15fd07b61552dad56bcdf9eba4be765c9396b2f79819505d4bb13cb04785
MD5 744b974c6297c07820732fb9ca826ece
BLAKE2b-256 22b95615f3c2d53f1cd4a9a9945430ea1161435befffea6fd1cb09a573ff1f75

See more details on using hashes here.

File details

Details for the file queuing-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: queuing-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for queuing-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42c358e103711aa97099a2a8ea74e819e49bccd78a691b3169f5489b0fe81eb6
MD5 07185f75bf4e691ffb39501dc3b261fd
BLAKE2b-256 74ae71bb074f27e5d75dc8ba578291e952925203e41db4290993155289762eb4

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