Ejemplo n.º 1
0
def f(sem, q):
    with sem:
        pid = getpid()
        ts = time.time()
        msg = 'process: {} - timestamp: {}'.format(pid, ts)
        q.put(msg)
        time.sleep(3)
Ejemplo n.º 2
0
def f(lock, q):
    with lock:
        pid = getpid()
        ts = time.time()
        msg = 'process: {} - timestamp: {}'.format(pid, ts)
        q.put(msg)
        time.sleep(1)
Ejemplo n.º 3
0
def f(q):
    print("I'm process {}".format(getpid()))
    q.put([42, None, 'hello'])
    for i in range(3):
        q.put('Message no. {} ({})'.format(i, time.time()))
        time.sleep(1)
    print('Done')
Ejemplo n.º 4
0
def f(q):
    print("I'm process {}".format(getpid()))

    # q.put([42, None, 'hello'])
    # for i in range(3):
    #     q.put('Message no. {} ({})'.format(i, time.time()))
    #     time.sleep(1)
    # print('Done')

    print(q.get())  # prints "[42, None, 'hello']"
    consuming = True
    while consuming:
        try:
            res = q.get()
            print(res)
        except q.Empty as e:
            print('Queue empty!')
            consuming = False
Ejemplo n.º 5
0
def f(barrier, q):
    barrier.wait()
    pid = getpid()
    ts = time.time()
    msg = 'process: {} - timestamp: {}'.format(pid, ts)
    q.put(msg)
Ejemplo n.º 6
0
def f(q):
    print("I'm process", getpid())
    q.put([42, None, 'hello'])
    time.sleep(5)