Go-style Chan for Python
Implements Go’s chan type in Python.
Install with pip install chan
Source at http://github.com/stuglaser/pychan
Usage
You can put onto channels, and get from them
c = Chan()
# Thread 1
c.put("Hello")
# Thread 2
print "Heard: %s" % c.get()
Channels can be closed (usually by the sender). Iterating over a channel gives all values until the channel is closed
c = Chan()
# Thread 1
c.put("It's")
c.put("just")
c.put("contradiction")
# Thread 2
for thing in c:
print "Heard:", thing
You can wait on multiple channels using chanselect. Pass it a list of input channels and another of output channels, and it will return when any of the channels is ready
def fan_in(outchan, input1, input2):
while True:
chan, value = chanselect([input1, input2], [])
if chan == input1:
outchan.put("From 1: " + str(value))
else:
outchan.put("From 2 " + str(value))
You can see more examples in the “examples” directory.
Metadata
Release files for chan 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chan-0.3.1.tar.gz | 6.5 kB | Without provenance | Details for chan-0.3.1.tar.gz |
Release files / chan-0.3.1.tar.gz
| Download URL | chan-0.3.1.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8dd6fb3478513f14190357459ac9db24fc43bf8715edd5135a66460402fc1180
|
|
BLAKE2b-256 checksum How to use checksums |
a436f9cdba9b26df384d3c6c0e85fd1e9692f7a778de2906ad2d12cacacc0fa5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for chan 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.