Requeue
In applications that receive messages, like chat bots, where you run callbacks on incoming messages, you might want to capture follow-up messages within a callback. A request queue allows you to do that.
Examples
from requeue import Requeue
queue = Requeue()
Where the messages come in and are processed;
async def run_callbacks(message):
# If the message completes a request, since it is forwarded,
# it should not continue to be handled by the callbacks.
if await queue.complete(message):
return
# If no request was completed, the message can be processed as usual.
for callback in client.callbacks:
await callback(message)
Inside a callback, to request and await an incoming message, you use wait_for.
To only accept a message that meets specific criteria, you can pass a function
as a filter to the check parameter.
@client.callback
async def on_message(message):
# An example of a knock knock joke back-and-forth,
# using the request queue to pick out the responses
if message == 'Knock knock!':
await client.send("Who's there?")
who, = await queue.wait_for()
await client.send(f'{who} who?')
punchline, = await queue.wait_for()
await punchline.react('😂')
Metadata
Release files for requeue 0.4.0
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 |
|---|---|---|---|---|
| requeue-0.4.0.tar.gz | 14.6 kB | Without provenance | Details for requeue-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| requeue-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for requeue-0.4.0-py3-none-any.whl |
Total release size: 29.8 kB
Release files / requeue-0.4.0.tar.gz
| Download URL | requeue-0.4.0.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
132661c5deeedb8e8a1dafed3134de2b195b60fccf026270e6669e692d6f30c6
|
|
BLAKE2b-256 checksum How to use checksums |
8c1ea63eaf6cb96f7cc7775c6328e4ea985393b2c8df8475f60db6991af6f439
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / requeue-0.4.0-py3-none-any.whl
| Download URL | requeue-0.4.0-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93ff23e8677709718870d6b3e1b4bbf63712bc6a23015d5d119c4fd59fbf1a43
|
|
BLAKE2b-256 checksum How to use checksums |
6151015aae96e3bbbb560802f4700a574454074cce8c34332f48b23ec1f048ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for requeue 0.4.0
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.