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

Resource Warning Logs #12

Open
jasonacox opened this issue Jan 3, 2025 · 1 comment
Open

Resource Warning Logs #12

jasonacox opened this issue Jan 3, 2025 · 1 comment

Comments

@jasonacox
Copy link
Owner

The error logs are indicating a research warning on closed connections:

/usr/local/lib/python3.10/site-packages/openai/resources/files.py:767: ResourceWarning: unclosed <socket.socket fd=30, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.17.0.2', 49524), raddr=('10.0.1.25', 8000)>
  self.content = async_to_custom_streamed_response_wrapper(
Object allocated at (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/base_events.py", lineno 946
    sock = socket.socket(family=family, type=type_, proto=proto)
/usr/local/lib/python3.10/asyncio/selector_events.py:710: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=30 read=idle write=<idle, bufsize=0>>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
Object allocated at (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", lineno 61
    return _SelectorSocketTransport(self, sock, protocol, waiter,
/usr/local/lib/python3.10/asyncio/selector_events.py:710: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=27 read=idle write=<idle, bufsize=0>>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
Object allocated at (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", lineno 61
    return _SelectorSocketTransport(self, sock, protocol, waiter,

The chatbot uses socketio to stay connected to clients and has a session disconnect handler so I'm not clear as to where this might be. Adding here for more research.

@jasonacox
Copy link
Owner Author

I was able to remove the warning by closing the openai client connection after each non-streaming call. There may be another way to handle this that is more efficient (e.g. connection pooling) but will require some research on the openai module.

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

No branches or pull requests

1 participant