zeromq / zbroker

Elastic pipes
Mozilla Public License 2.0
50 stars 11 forks source link

reader/writer issue #41

Closed rpedde closed 10 years ago

rpedde commented 10 years ago

Not sure how this goes wrong, but...

open reader and writer write small amount of data attempt to read a large amount of data (blocks, too small) close write handle

at this point, expected is that reader returns the data in buffer, and subsequent read returns 0. instead, the reader gets dropped, the read request blocks, and the pipe doesn't terminate.

I'll post traces in a bit

rpedde commented 10 years ago
14-04-25 15:22:58     88: start:
14-04-25 15:22:58     88:     INPUT
14-04-25 15:22:58     88:         $ lookup or create pipe
14-04-25 15:22:58     88:         $ open pipe reader
14-04-25 15:22:58     88:         > before reading
14-04-25 15:22:58     88: before reading:
14-04-25 15:22:58     88:     ok
14-04-25 15:22:58     88:         $ send INPUT_OK
14-04-25 15:22:58     88:         > reading
14-04-25 15:22:58     89: start:
14-04-25 15:22:58     89:     OUTPUT
14-04-25 15:22:58     89:         $ lookup or create pipe
14-04-25 15:22:58     89:         $ open pipe writer
14-04-25 15:22:58     89: start:
14-04-25 15:22:58     89:     have writer
14-04-25 15:22:58     89:         > start
14-04-25 15:22:58     89:         > before writing
14-04-25 15:22:58     89: before writing:
14-04-25 15:22:58     89:     ok
14-04-25 15:22:58     89:         $ send OUTPUT_OK
14-04-25 15:22:58     89:         > writing
14-04-25 15:22:58     88: reading:
14-04-25 15:22:58     88:     READ
14-04-25 15:22:58     88:         $ look for pipe data
14-04-25 15:22:58     88:         > processing read
14-04-25 15:22:58     89: writing:
14-04-25 15:22:58     89:     WRITE
14-04-25 15:22:58     89:         $ look for pipe reader
14-04-25 15:22:58     89:         > processing write
14-04-25 15:22:58     89: processing write:
14-04-25 15:22:58     89:     have reader
14-04-25 15:22:58     89:         $ pass data to reader
14-04-25 15:22:58     88: processing read:
14-04-25 15:22:58     88:     have data
14-04-25 15:22:58     88:         $ collect data to send
14-04-25 15:22:58     88:         ! not enough data
14-04-25 15:22:58     88:         > processing read
14-04-25 15:22:58     88: processing read:
14-04-25 15:22:58     88:     not enough data
14-04-25 15:22:58     88:         > processing read
14-04-25 15:22:58     89:         $ send WRITE_OK
14-04-25 15:22:58     89:         > writing
14-04-25 15:22:58     89: writing:
14-04-25 15:22:58     89:     CLOSE
14-04-25 15:22:58     89:         $ close pipe writer
14-04-25 15:22:58     88: processing read:
14-04-25 15:22:58     88:     writer dropped
14-04-25 15:22:58     88:         $ close pipe reader
CLOSE PIPE READER
DROP LOCAL PIPE READER
YES DROP LOCAL READER
NO WRITER APPARENTLY
14-04-25 15:22:58     88:         > processing read
14-04-25 15:22:58     89:         $ send CLOSE_OK
14-04-25 15:22:58     89:         > start

<kill process here >

14-04-25 15:23:58     88: processing read:
14-04-25 15:23:58     88:     expired
14-04-25 15:23:58     88:         $ close pipe reader
CLOSE PIPE READER
DROP LOCAL PIPE READER
14-04-25 15:23:58     88:         $ terminate
14-04-25 15:23:58     89: start:
14-04-25 15:23:58     89:     expired
14-04-25 15:23:58     89:         $ terminate
rpedde commented 10 years ago

From this:

def consumer(pipe):
    reader = zbroker.Zpipe('local|%s' % pipe)
    result = reader.read()
    reader.close()
    print 'read: %s' % result

def producer(pipe):
    writer = zbroker.Zpipe('local|>%s' % pipe)
    writer.write('test')
    writer.close()

t_consumer = threading.Thread(target=consumer, args=['woof'])
t_producer = threading.Thread(target=producer, args=['woof'])

t_consumer.start()
t_producer.start()

t_consumer.join()
t_producer.join()
hintjens commented 10 years ago

Nice, I'll add the test case.

On Fri, Apr 25, 2014 at 11:40 PM, Ron Pedde notifications@github.comwrote:

From this:

def consumer(pipe): reader = zbroker.Zpipe('local|%s' % pipe) result = reader.read() reader.close() print 'read: %s' % result

def producer(pipe): writer = zbroker.Zpipe('local|>%s' % pipe) writer.write('test') writer.close()

t_consumer = threading.Thread(target=consumer, args=['woof']) t_producer = threading.Thread(target=producer, args=['woof'])

t_consumer.start() t_producer.start()

t_consumer.join() t_producer.join()

— Reply to this email directly or view it on GitHubhttps://github.com/zeromq/zbroker/issues/41#issuecomment-41442246 .