Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

OS Error from client #1

Open
mattkantor opened this issue Feb 2, 2022 · 7 comments
Open

OS Error from client #1

mattkantor opened this issue Feb 2, 2022 · 7 comments

Comments

@mattkantor
Copy link

mattkantor commented Feb 2, 2022

Im attempting to use the new Python SDK (very nice design BTW). I'm making only the following call in pytest

self.client = Client(api_key=credentials['api_key'], max_delay=1, max_retries=1)

and when the tests finish, I see this :

Exception ignored in: <function ApiClient.__del__ at 0x13a0271f0> Traceback (most recent call last): File "/Users/matthewkantor/dev/bifrost/venv/lib/python3.8/site-packages/swagger_client/api_client.py", line 78, in __del__ self.pool.close() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/pool.py", line 649, in close self._change_notifier.put(None) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/queues.py", line 368, in put self._writer.send_bytes(obj) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes self._send_bytes(m[offset:offset + size]) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes self._send(header + buf) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/connection.py", line 368, in _send n = write(self._handle, buf) OSError: [Errno 9] Bad file descriptor

Im not even making any API calls, I'm just creating the client.

NOTE: This is happening on MacOS Python 3.8 venv. Pytest running on 3.8 in gitlab ci does not yield these results.

@mangoceylon
Copy link

Thanks for raising this, we will work to repro and provide guidance.

@amorphic
Copy link

amorphic commented Feb 4, 2022

I'm getting a similar issue at completion of a program on Ubuntu 21.04 w/Python 3.10.1:

import klaviyo_sdk

klaviyo_api_key = "XXXYYYZZZ"
klaviyo_list_id = "abc123"

client = klaviyo_sdk.Client(klaviyo_api_key, max_delay=60, max_retries=3)
members = client.ListsSegments.get_members(klaviyo_list_id)
print(members)

...

Exception ignored in: <function ApiClient.__del__ at 0x7fd67c4a3370>
Traceback (most recent call last):
  File "/home/james/.pyenv/versions/enstaved-metrics/lib/python3.10/site-packages/swagger_client/api_client.py", line 78, in __del__
    self.pool.close()
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/pool.py", line 649, in close
    self._change_notifier.put(None)
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/queues.py", line 378, in put
    self._writer.send_bytes(obj)
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 205, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 416, in _send_bytes
    self._send(header + buf)
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 373, in _send
    n = write(self._handle, buf)
OSError: [Errno 9] Bad file descriptor
Exception ignored in: <function ApiClient.__del__ at 0x7fd67c4a3370>
Traceback (most recent call last):
  File "/home/james/.pyenv/versions/enstaved-metrics/lib/python3.10/site-packages/swagger_client/api_client.py", line 78, in __del__
    self.pool.close()
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/pool.py", line 649, in close
    self._change_notifier.put(None)
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/queues.py", line 378, in put
    self._writer.send_bytes(obj)
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 205, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 416, in _send_bytes
    self._send(header + buf)
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 373, in _send
    n = write(self._handle, buf)
OSError: [Errno 9] Bad file descriptor
Exception ignored in: <function ApiClient.__del__ at 0x7fd67c4a3370>
Traceback (most recent call last):
  File "/home/james/.pyenv/versions/enstaved-metrics/lib/python3.10/site-packages/swagger_client/api_client.py", line 78, in __del__
    self.pool.close()
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/pool.py", line 649, in close
    self._change_notifier.put(None)
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/queues.py", line 378, in put
    self._writer.send_bytes(obj)
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 205, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 416, in _send_bytes
    self._send(header + buf)
  File "/home/james/.pyenv/versions/3.10.1/lib/python3.10/multiprocessing/connection.py", line 373, in _send
    n = write(self._handle, buf)
OSError: [Errno 9] Bad file descriptor

@dano-klaviyo
Copy link
Collaborator

@amorphic I can't seem to replicate that under ubuntu 21.10 /w python 3.10.1. Can you give me more detail on your setup.

  • Are you using pyenv?
  • approximately how big is the list
  • do you consistently get the OSError: [Errno 9] Bad file descriptor
  • would you be able to try your program on ubuntu 21.10 instead of 21.04?

@dano-klaviyo
Copy link
Collaborator

@mattkantor Is your macbook powered by m1 or intel? Also what is the version of macOS you tried this on? Also do you use pyenv? Any other info would be also helpful.

@mattkantor
Copy link
Author

mattkantor commented Feb 8, 2022

@dano-klaviyo This happens on my M1 (under rosetta) but also under ubuntu in Gitlab CI. I read something about swagger_client having issues with the del method which calls pool.close() - I tried to resolved using 3.9 but no luck.

I use virtualenv.

@amorphic
Copy link

amorphic commented Feb 9, 2022

@dano-klaviyo

  • Yep I'm using pyenv
  • The list is brand new and only has 1 member
  • Yep I get the error after every run
  • I can't try Ubuntu 21.10 right now but should be able to over the coming days. However I suspect that won't make a difference if I'm using pyenv and the same python version.

@kbehlers
Copy link

I read something about swagger_client having issues with the del method which calls pool.close()

The approach used by swagger-codegen for cleaning up pools is apparently unsupported by CPython, but the openapi-generator fork seems to have accepted a fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants