René's URL Explorer Experiment


Title: Prevent deadlock with urllib3 logging during shutdown + add bounded f… by oesi333 · Pull Request #37 · logtail/logtail-python · GitHub

Open Graph Title: Prevent deadlock with urllib3 logging during shutdown + add bounded f… by oesi333 · Pull Request #37 · logtail/logtail-python

X Title: Prevent deadlock with urllib3 logging during shutdown + add bounded f… by oesi333 · Pull Request #37 · logtail/logtail-python

Description: Problem LogtailHandler.flush() can deadlock the host process when called during logging.shutdown() / logging.config.dictConfig(). This is reachable in real-world setups - e.g. anyone using pymilvus (which calls dictConfig() at module import time) alongside logtail-python. We hit it deterministically when BetterStack was slow. Stack trace from py-spy dump on the deadlocked process MainThread: flush (logtail/flusher.py:83) flush (logtail/handler.py:81) shutdown (logging/init.py:2182) _clearExistingHandlers (logging/config.py:275) configure (logging/config.py:544) dictConfig (logging/config.py:811) init_log (pymilvus/settings.py:99) (pymilvus/settings.py:102) ... Thread-1 (FlushWorker): _acquireLock (logging/init.py:226) isEnabledFor (logging/init.py:1734) debug (logging/init.py:1464) _make_request (urllib3/connectionpool.py:556) urlopen (urllib3/connectionpool.py:803) send (requests/adapters.py:658) ... call (logtail/uploader.py:24) step (logtail/flusher.py:67) run (logtail/flusher.py:27) MainThread holds logging._lock (acquired inside _clearExistingHandlers) while waiting for the FlushWorker to drain. The FlushWorker is in urllib3._make_request, which calls logger.debug(...) - also needing logging._lock. Classic A-waits-B, B-waits-A. Fix Two complementary changes: Quiet urllib3 to WARNING when logtail/handler.py is imported (opt-out via LOGTAIL_KEEP_URLLIB3_LOGS=1). This makes urllib3's per-request debug() calls cheap no-ops, so the FlushWorker no longer needs logging._lock during uploads. Existing higher-than-WARNING urllib3 levels are left untouched. Bound LogtailHandler.flush() with a flush_timeout (default 30s; pass None for legacy unbounded). FlushWorker.flush() now accepts timeout and returns True/False on drained/timed-out. This prevents shutdown from hanging the host process if BetterStack is slow/unreachable, and bounds any future similar deadlock window. Tests Five new unit tests, all 31 non-hanging tests pass. (The pre-existing test_can_send_* tests in test_handler.py hang on master too — separate issue.) Backwards compatibility LogtailHandler(...) — new optional kwarg flush_timeout=30. Existing callers unaffected. FlushWorker.flush() — new optional timeout kwarg, defaults to None (legacy unbounded). Callers passing no args get the same behavior as before. urllib3 quieting — opt-out env var preserves original behavior for users who depend on urllib3 DEBUG logs.

Open Graph Description: Problem LogtailHandler.flush() can deadlock the host process when called during logging.shutdown() / logging.config.dictConfig(). This is reachable in real-world setups - e.g. anyone using pymilvus...

X Description: Problem LogtailHandler.flush() can deadlock the host process when called during logging.shutdown() / logging.config.dictConfig(). This is reachable in real-world setups - e.g. anyone using pymilvus...

Opengraph URL: https://github.com/logtail/logtail-python/pull/37

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:3bbecd3f-2dc7-97dd-89bf-2b53e85e1b26
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD442:2668B6:29D404:38CA01:6AFBB07B
html-safe-noncec05b8aa65e5ff809c5391c8ca67a6357cb6d19e8380026cc8cc3ba34ea300430
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDQyOjI2NjhCNjoyOUQ0MDQ6MzhDQTAxOjZBRkJCMDdCIiwidmlzaXRvcl9pZCI6Ijc3MjY2MDE4NzMzMDExNTU5NjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb39ceadf9e47572cae463fc01b9a42dbad7e3ff07a805ae030d873c9ff7f755e
hovercard-subject-tagpull_request:3603704875
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/logtail/logtail-python/pull/37/files
twitter:imagehttps://avatars.githubusercontent.com/u/53701969?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/53701969?s=400&v=4
og:image:altProblem LogtailHandler.flush() can deadlock the host process when called during logging.shutdown() / logging.config.dictConfig(). This is reachable in real-world setups - e.g. anyone using pymilvus...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonee25fbd830d3e6ad0e8935c105cf4fdc70c593dffcd27bb45b790ae4fece5ea55
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/logtail/logtail-python git https://github.com/logtail/logtail-python.git
octolytics-dimension-user_id78922349
octolytics-dimension-user_loginlogtail
octolytics-dimension-repository_id351343852
octolytics-dimension-repository_nwologtail/logtail-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id351343852
octolytics-dimension-repository_network_root_nwologtail/logtail-python
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release08c8f17f9d27054a108b8b6254e405de0151f660
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/logtail/logtail-python/pull/37/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flogtail%2Flogtail-python%2Fpull%2F37%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flogtail%2Flogtail-python%2Fpull%2F37%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=logtail%2Flogtail-python
Reloadhttps://github.com/logtail/logtail-python/pull/37/files
Reloadhttps://github.com/logtail/logtail-python/pull/37/files
Reloadhttps://github.com/logtail/logtail-python/pull/37/files
logtailhttps://github.com/logtail
logtail-pythonhttps://github.com/logtail/logtail-python
Codehttps://github.com/logtail/logtail-python
Issues1 (1)https://github.com/logtail/logtail-python/issues
Pull requestshttps://github.com/logtail/logtail-python/pulls
Actionshttps://github.com/logtail/logtail-python/actions
Security and qualityhttps://github.com/logtail/logtail-python/security
Insightshttps://github.com/logtail/logtail-python/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Flogtail%2Flogtail-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Flogtail%2Flogtail-python%2Fissues%2Fnew%2Fchoose
oesi333https://github.com/oesi333
logtail:masterhttps://github.com/logtail/logtail-python/tree/master
oesi333:fix/flush-deadlock-with-urllib3-debug-logginghttps://github.com/oesi333/logtail-python/tree/fix/flush-deadlock-with-urllib3-debug-logging
Conversation 1 https://github.com/logtail/logtail-python/pull/37
Commits 1 https://github.com/logtail/logtail-python/pull/37/commits
Checks 0 https://github.com/logtail/logtail-python/pull/37/checks
Files changed https://github.com/logtail/logtail-python/pull/37/files
Please reload this pagehttps://github.com/logtail/logtail-python/pull/37/files
Prevent deadlock with urllib3 logging during shutdown + add bounded f… https://github.com/logtail/logtail-python/pull/37/files#top
Show all changes 1 commit https://github.com/logtail/logtail-python/pull/37/files
a7a14b3 Prevent deadlock with urllib3 logging during shutdown + add bounded f… oesi333 Apr 29, 2026 https://github.com/logtail/logtail-python/pull/37/commits/a7a14b3962f2d5670e1f7739ba3a88bfbf77af12
Clear filters https://github.com/logtail/logtail-python/pull/37/files
Please reload this pagehttps://github.com/logtail/logtail-python/pull/37/files
Please reload this pagehttps://github.com/logtail/logtail-python/pull/37/files
flusher.py https://github.com/logtail/logtail-python/pull/37/files#diff-8a07bff24d8cc7c814a976f4c2db795ba1fff25f57eb18f3dd5203c2e77ef533
handler.py https://github.com/logtail/logtail-python/pull/37/files#diff-a9b0950e5b1ec28ff945c773b108d8b4b6617bfdbee33319a137ec929317e2cd
test_flusher.py https://github.com/logtail/logtail-python/pull/37/files#diff-f17c869b31f30e711632530bb52ff81b91a288179d365ff7776c8a7cb24c6db9
test_handler.py https://github.com/logtail/logtail-python/pull/37/files#diff-3f86b181ab338949acfc1d27ff975b666acd3f0b016eb4bcce7c79fab09e463b
logtail/flusher.pyhttps://github.com/logtail/logtail-python/pull/37/files#diff-8a07bff24d8cc7c814a976f4c2db795ba1fff25f57eb18f3dd5203c2e77ef533
View file https://github.com/oesi333/logtail-python/blob/a7a14b3962f2d5670e1f7739ba3a88bfbf77af12/logtail/flusher.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/logtail/logtail-python/pull/37/{{ revealButtonHref }}
https://github.com/logtail/logtail-python/pull/37/files#diff-8a07bff24d8cc7c814a976f4c2db795ba1fff25f57eb18f3dd5203c2e77ef533
https://github.com/logtail/logtail-python/pull/37/files#diff-8a07bff24d8cc7c814a976f4c2db795ba1fff25f57eb18f3dd5203c2e77ef533
logtail/handler.pyhttps://github.com/logtail/logtail-python/pull/37/files#diff-a9b0950e5b1ec28ff945c773b108d8b4b6617bfdbee33319a137ec929317e2cd
View file https://github.com/oesi333/logtail-python/blob/a7a14b3962f2d5670e1f7739ba3a88bfbf77af12/logtail/handler.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/logtail/logtail-python/pull/37/{{ revealButtonHref }}
https://github.com/logtail/logtail-python/pull/37/files#diff-a9b0950e5b1ec28ff945c773b108d8b4b6617bfdbee33319a137ec929317e2cd
https://github.com/logtail/logtail-python/pull/37/files#diff-a9b0950e5b1ec28ff945c773b108d8b4b6617bfdbee33319a137ec929317e2cd
https://github.com/logtail/logtail-python/pull/37/files#diff-a9b0950e5b1ec28ff945c773b108d8b4b6617bfdbee33319a137ec929317e2cd
https://github.com/logtail/logtail-python/pull/37/files#diff-a9b0950e5b1ec28ff945c773b108d8b4b6617bfdbee33319a137ec929317e2cd
https://github.com/logtail/logtail-python/pull/37/files#diff-a9b0950e5b1ec28ff945c773b108d8b4b6617bfdbee33319a137ec929317e2cd
https://github.com/logtail/logtail-python/pull/37/files#diff-a9b0950e5b1ec28ff945c773b108d8b4b6617bfdbee33319a137ec929317e2cd
tests/test_flusher.pyhttps://github.com/logtail/logtail-python/pull/37/files#diff-f17c869b31f30e711632530bb52ff81b91a288179d365ff7776c8a7cb24c6db9
View file https://github.com/oesi333/logtail-python/blob/a7a14b3962f2d5670e1f7739ba3a88bfbf77af12/tests/test_flusher.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/logtail/logtail-python/pull/37/{{ revealButtonHref }}
https://github.com/logtail/logtail-python/pull/37/files#diff-f17c869b31f30e711632530bb52ff81b91a288179d365ff7776c8a7cb24c6db9
tests/test_handler.pyhttps://github.com/logtail/logtail-python/pull/37/files#diff-3f86b181ab338949acfc1d27ff975b666acd3f0b016eb4bcce7c79fab09e463b
View file https://github.com/oesi333/logtail-python/blob/a7a14b3962f2d5670e1f7739ba3a88bfbf77af12/tests/test_handler.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/logtail/logtail-python/pull/37/{{ revealButtonHref }}
https://github.com/logtail/logtail-python/pull/37/files#diff-3f86b181ab338949acfc1d27ff975b666acd3f0b016eb4bcce7c79fab09e463b
https://github.com/logtail/logtail-python/pull/37/files#diff-3f86b181ab338949acfc1d27ff975b666acd3f0b016eb4bcce7c79fab09e463b
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.