Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename socket.py to listen_socket.py to avoid circular import #5373

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

diwu-sf
Copy link
Contributor

@diwu-sf diwu-sf commented Dec 2, 2024

Running python openhands/server/listen.py will show this import error, due to socket.py naming conflict:

Traceback (most recent call last):
  File "OpenHands/openhands/server/listen.py", line 1, in <module>
    import socketio
  File "openhands-ai-uMz2TtsD-py3.12/lib/python3.12/site-packages/socketio/__init__.py", line 1, in <module>
    from .client import Client
  File "openhands-ai-uMz2TtsD-py3.12/lib/python3.12/site-packages/socketio/client.py", line 3, in <module>
    import engineio
  File "openhands-ai-uMz2TtsD-py3.12/lib/python3.12/site-packages/engineio/__init__.py", line 1, in <module>
    from .client import Client
  File "openhands-ai-uMz2TtsD-py3.12/lib/python3.12/site-packages/engineio/client.py", line 5, in <module>
    import ssl
  File "miniconda3/lib/python3.12/ssl.py", line 260, in <module>
    from socket import socket, SOCK_STREAM, create_connection
  File "OpenHands/openhands/server/socket.py", line 1, in <module>
    from fastapi import status
  File "openhands-ai-uMz2TtsD-py3.12/lib/python3.12/site-packages/fastapi/__init__.py", line 7, in <module>
    from .applications import FastAPI as FastAPI
  File "openhands-ai-uMz2TtsD-py3.12/lib/python3.12/site-packages/fastapi/applications.py", line 16, in <module>
    from fastapi import routing
  File "openhands-ai-uMz2TtsD-py3.12/lib/python3.12/site-packages/fastapi/routing.py", line 1, in <module>
    import asyncio
  File "miniconda3/lib/python3.12/asyncio/__init__.py", line 8, in <module>
    from .base_events import *
  File "miniconda3/lib/python3.12/asyncio/base_events.py", line 41, in <module>
    from . import events
  File "miniconda3/lib/python3.12/asyncio/events.py", line 211, in <module>
    class AbstractEventLoop:
  File "miniconda3/lib/python3.12/asyncio/events.py", line 320, in AbstractEventLoop
    *, family=socket.AF_UNSPEC,
              ^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'socket' has no attribute 'AF_UNSPEC' (most likely due to a circular import)

@enyst enyst requested a review from tofarr December 2, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant