Opened 5 years ago

Closed 3 years ago

#3835 enhancement closed fixed (fixed)

The producer/consumer howto could really do with some examples

Reported by: itamar Owned by: thijs
Priority: normal Milestone:
Component: core Keywords: documentation
Cc: thijs, ruttbe Branch: branches/streaming-example-3835
(diff, github, buildbot, log)
Author: ruttbe, thijs Launchpad Bug:

Description

The current version of the producer/consumer howto is more of a reference. Some examples involving transports would make it easier to assimilate. It's a bit problematic though since transports are both most common consumers and most common source of data for producers, which might be confusing. But the examples should at least show some transport integration.

Change History (17)

comment:1 Changed 5 years ago by thijs

  • Cc thijs added

comment:2 Changed 5 years ago by glyph

  • Owner changed from glyph to thijs

comment:3 Changed 5 years ago by thijs

#4171 was a duplicate of this and contains an example.

comment:4 Changed 5 years ago by thijs

  • Author set to thijs
  • Branch set to branches/streaming-example-3835

(In [28001]) Branching to 'streaming-example-3835'

comment:5 Changed 5 years ago by thijs

  • Author changed from thijs to ruttbe, thijs
  • Cc ruttbe added
  • Status changed from new to assigned

comment:6 Changed 5 years ago by thijs

(In [28002]) Add streaming.py example, refs #3835, #4171

comment:7 Changed 4 years ago by thijs

(In [30518]) apply coding standard, add to examples listing and news file. refs #3835

comment:8 Changed 4 years ago by thijs

  • Keywords review added
  • Owner thijs deleted
  • Status changed from assigned to new

comment:9 follow-up: Changed 3 years ago by exarkun

  • Keywords review removed
  • Owner set to thijs
  1. cnt is a silly variable name. Please switch to count.
  2. There's lots of extra parenthesis where print is used.
  3. The example doesn't actually require Python 2.6, it works fine on 2.4. The last sentence of the docstring can probably just go.
  4. random.randrange is preferred over random.randint
  5. ServeRandom should use sendLine instead of transport.write in connectionMade
  6. The pauseProducing docstring is nice. How about some for the other methods?
  7. stopProducing should cause the resumeProducing loop to stop, too.
  8. The vertical whitespace needs some cleanup.
  9. The producer/consumer howto should link to this example.

Thanks!

comment:10 Changed 3 years ago by thijs

  • Status changed from new to assigned

comment:11 Changed 3 years ago by thijs

(In [30760]) address review comments, refs #3835

comment:12 in reply to: ↑ 9 Changed 3 years ago by thijs

  • Keywords review added
  • Owner thijs deleted
  • Status changed from assigned to new

Up for 500 points.. :)

comment:13 Changed 3 years ago by mithrandi

  • Keywords review removed
  • Owner set to thijs

This example only implements a push producer, which is somewhat different from a pull producer. I think the various references to "example of a producer" (or similar wording) should explicitly mention that this is a push producer, to avoid confusion.

Aside from that, everything else looks good; please go ahead and merge once that issue is dealt with.

comment:14 Changed 3 years ago by thijs

  • Status changed from new to assigned

comment:15 Changed 3 years ago by thijs

(In [31631]) add references to push producer, refs #3835

comment:16 Changed 3 years ago by thijs

(In [31632]) reference push producer, refs #3835

comment:17 Changed 3 years ago by thijs

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [31633]) Added sample implementation of a Twisted push producer/consumer system.

Author: ruttbe, thijs
Reviewer: exarkun, mithrandi
Fixes: #3835

Note: See TracTickets for help on using tickets.