Comments (4)
As a quick fix you can probably import trio
before monkey patching. This will cache trio with un-patched system things.
There has to be a way to fix this that isn't just a game of whack-a-mole but I don't have any ideas.
from trio.
If I import trio before monkey patching it will fall with "AttributeError: module 'select' has no attribute 'epoll'".
I ended up with this to avoid both attribute errors:
def monkey_patch_trio():
try:
import select
if not hasattr(select, 'epoll'):
class FakeEpoll:
def __init__(self, *args, **kwargs):
raise NotImplementedError("epoll is not supported on this platform")
fake_select_module = ModuleType("select")
fake_select_module.epoll = FakeEpoll
sys.modules["select"] = fake_select_module
# Patch GreenSocket before trio._socket is imported
from eventlet.greenio.base import GreenSocket as EventletGreenSocket
if not hasattr(EventletGreenSocket, 'sendmsg'):
setattr(EventletGreenSocket, 'sendmsg', lambda *args, **kwargs: None)
if not hasattr(EventletGreenSocket, 'recvmsg'):
setattr(EventletGreenSocket, 'recvmsg', lambda *args, **kwargs: None)
if not hasattr(EventletGreenSocket, 'recvmsg_into'):
setattr(EventletGreenSocket, 'recvmsg_into', lambda *args, **kwargs: None)
# Now import trio._socket
import trio._socket as trio_socket
import socket as _stdlib_socket
from functools import wraps as _wraps
class PatchedSocketType(trio_socket.SocketType):
@_wraps(_stdlib_socket.socket.sendmsg, assigned=(), updated=())
def sendmsg(self, *args, **kwargs):
raise NotImplementedError("sendmsg is not supported on this platform")
@_wraps(_stdlib_socket.socket.recvmsg, assigned=(), updated=())
def recvmsg(self, *args, **kwargs):
raise NotImplementedError("recvmsg is not supported on this platform")
@_wraps(_stdlib_socket.socket.recvmsg_into, assigned=(), updated=())
def recvmsg_into(self, *args, **kwargs):
raise NotImplementedError("recvmsg_into is not supported on this platform")
trio_socket.SocketType = PatchedSocketType
except ImportError:
pass
from trio.
Sorry, I mean import trio
before running eventlet.monkey_patch()
.
from trio.
Ok I thought about this some more and this is totally just an eventlet bug. They claim GreenSocket
is "100% api compatible with socket.socket
":
from trio.
Related Issues (20)
- Remove (Deprecate??) TrioDeprecationWarning HOT 4
- > (my perspective is someone who uses Trio for concurrency uses and very much a networking noob!)
- open_nursery is unable to call move_on_after when it is active, but it can still work. HOT 2
- Remaining test issues with Python 3.13.0b1: not ki_protected, pathlib.Path.resolve siganture HOT 6
- Ctrl+C behavior problems at the new REPL HOT 7
- Would be to actually port aiomultiprocess to trio? HOT 1
- No support aiohttp? HOT 2
- Trio fails under gevent with NotImplementedError: unsupported platform HOT 11
- Add `TypeVarTuple` to `Nursery.start` HOT 3
- unexpected StopAsyncIteration HOT 6
- Why can't you await __aenter__? (Understanding trio's contracts around async context managers) HOT 5
- Problems with `trio.Lock()` across multiple tasks HOT 4
- exception forwarding in from_thread.run HOT 3
- Regression: unix socket bind does not work with a PathLike argument HOT 3
- Add a Github Action that checks for newsfragment
- move_on_ and fail_ functions should accept shield as a keyword argument
- Using trio with attrs 24.1.0 raises a warning HOT 4
- Make no-test-dependencies CI run use locked resolutions
- Make sure trio works with Read the Docs Addons
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trio.