question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to properly timeout a notification listener?

See original GitHub issue

I need to load an object from MinIO as soon as it is uploaded. For that, I use the MinIO python client’s Minio.listen_bucket_notification() and listen for the “s3:ObjectCreated:*” event. The client only listens for a single object.

It can happen that the file does not get created in time. So I want to stop listening for this notification after a while. Looking at the implementation (https://github.com/minio/minio-py/blob/master/minio/api.py#L868), I don’t see an option for a timeout, or any proper way for me to close the response and release the connection to MinIO from the outside.

What is the proper way to time out a MinIO client’s listen_bucket_notification() iterator?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
neuneckcommented, Jun 25, 2021

Thank you for the quick action @balamurugana

0reactions
neuneckcommented, Jun 25, 2021

FYI: I also verified that using the events object directly, i.e. not as a context manager will leak the connection. Running

from minio.api import Minio
from iterators import TimeoutIterator

minio_client = Minio(endpoint="127.0.0.1:9000",
                     access_key="AKIAIOSFODNN7EXAMPLE",
                     secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
                     secure=False)


if not minio_client.bucket_exists("example"):
    minio_client.make_bucket("example")

events = minio_client.listen_bucket_notification("example")
it = TimeoutIterator(events, timeout=5)
for event in it:
    if event is it.get_sentinel():
        print("Sentinel received")
        break
    else:
        print("event")

print(events)
print(events._response)

Gives

Sentinel received
<minio.datatypes.EventIterable object at 0x7f5c9991ab80>
<urllib3.response.HTTPResponse object at 0x7f5c998cc5e0>

Whereas the code above gives

Sentinel received
<minio.datatypes.EventIterable object at 0x7f294a781b80>
None
Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - How to properly timeout a notification listener? -
I need to load an object from MinIO as soon as it is uploaded. For that, I use the MinIO python client's Minio.listen_bucket_notification()...
Read more >
Android Notification Timeout Listener - Stack Overflow
There's nothing like a timeout listener but you can use a delete intent for your purpose. You'll need a Broadcast Receiver in order...
Read more >
NotificationListenerService - Android Developers
Notification was canceled due to timeout. int, REASON_UNAUTOBUNDLED. Autobundled summary notification was canceled because its group was unbundled.
Read more >
How can I get notified when timeout happen? - Forum
I got a timeout errors due to network maintenance on EaaS ADS. I'd like to know how can I register a listener in...
Read more >
Time-Out | Essentials | Parenting Information - CDC
What if my child is not quiet during time-out? When you first start using time-out, your child may scream or cry. This behavior...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found