Immutable solution version
Asserterror when using in flask app, gevent, magic libraries
Complete solution
[davidhewitt (commenter)]: The AssertionError is an upstream gevent + ctypes interaction (opentelemetry-python#3897). Workaround: import gevent and magic before calling logfire.configure().
Pydantic Logfire - ### Description
The error below happens only when using the combination of gevent, logfire, and importing magic.
The fix
[davidhewitt (commenter)]: The AssertionError is an upstream gevent + ctypes interaction (opentelemetry-python#3897). Workaround: import gevent and magic before calling logfire.configure(). Run gevent.monkey.patch_all() and all third-party imports first, then configure logfire last.
Thread: gh:pydantic/logfire#63
Evidence
In gh:pydantic/logfire#63 (https://github.com/pydantic/logfire/issues/63), the issue reported: ### Description
The error below happens only when using the combination of gevent, logfire, and importing magic.
Full code:
import gevent.monkey
gevent.monkey.patch_all()
import logfire
logfire.configure(token [your value]
# todo doing this import shows the error
import magic
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "[p]Hello, World![/p]"
if __name__ == "__main__":
app.run()
Logfire project URL:... The verified answer: [davidhewitt (commenter)]: The AssertionError is an upstream gevent + ctypes interaction (opentelemetry-python#3897). Workaround: import gevent and magic before calling logfire.configure(). Run gevent.monkey.patch_all() and all third-party imports first, then configure logfire last.By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Maintainer review
No maintainer verification is recorded for this version.
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_3QOjT4ZvEnTFc9OmXqdHaw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Asserterror when using in flask app, gevent, magic libraries <span>— Vectle</span></a>