Code Monkey home page Code Monkey logo

Comments (4)

dvarrazzo avatar dvarrazzo commented on May 29, 2024

Ah I see.

Can you try to apply the following diff:

diff --git a/psycopg3/psycopg3/waiting.py b/psycopg3/psycopg3/waiting.py
index bfab413..e607024 100644
--- a/psycopg3/psycopg3/waiting.py
+++ b/psycopg3/psycopg3/waiting.py
@@ -196,13 +196,6 @@ async def wait_conn_async(gen: PQGenConn[RV]) -> RV:
         return rv
 
 
-poll_evmasks = {
-    Wait.R: select.EPOLLONESHOT | select.EPOLLIN,
-    Wait.W: select.EPOLLONESHOT | select.EPOLLOUT,
-    Wait.RW: select.EPOLLONESHOT | select.EPOLLIN | select.EPOLLOUT,
-}
-
-
 def wait_epoll(
     gen: PQGen[RV], fileno: int, timeout: Optional[float] = None
 ) -> RV:
@@ -247,5 +240,12 @@ if (
     is selectors.EpollSelector
 ):
     wait = wait_epoll
+
+    poll_evmasks = {
+        Wait.R: select.EPOLLONESHOT | select.EPOLLIN,
+        Wait.W: select.EPOLLONESHOT | select.EPOLLOUT,
+        Wait.RW: select.EPOLLONESHOT | select.EPOLLIN | select.EPOLLOUT,
+    }
+
 else:
     wait = wait_selector

If it work I'll commit it to master

from psycopg.

dvarrazzo avatar dvarrazzo commented on May 29, 2024

I have applied the diff to master. Please let us know if it fixes your problem. There might be others as macOS is untested

from psycopg.

jacopofar avatar jacopofar commented on May 29, 2024

The error changed. Now it is:

  File "/Users/jacopo/projects/pgtest/.venv/lib/python3.9/site-packages/psycopg3/waiting.py", line 240, in <module>
    is getattr(selectors, 'EpollSelector')
AttributeError: module 'selectors' has no attribute 'EpollSelector'

On my system dir(selector) shows these attributes:

'ABCMeta', 'BaseSelector', 'DefaultSelector', 'EVENT_READ', 'EVENT_WRITE', 'KqueueSelector', 'Mapping', 'PollSelector', 'SelectSelector', 'SelectorKey', '_BaseSelectorImpl', '_PollLikeSelector', '_SelectorMapping', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_can_use', '_fileobj_to_fd', 'abstractmethod', 'math', 'namedtuple', 'select', 'sys'

It seems epoll is available only on Linux, but if I change the code to getattr(selectors, 'EpollSelector', None) in the check then it falls back to wait_selector and I can run the example code without problems.

from psycopg.

dvarrazzo avatar dvarrazzo commented on May 29, 2024

Thank you, good to know. I will make this changeset too in master.

from psycopg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.