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

pyNetBox throws exception ConnectionError when allocating an IP, even if it was successfully allocated #526

Closed
Yuliya-H opened this issue Dec 26, 2022 · 3 comments

Comments

@Yuliya-H
Copy link

Trying to allocate IP in a few threads in parallel via :

avail_ips = DetailEndpoint(iprange, "available-ips", custom_return=IpAddresses)
address = avail_ips.create()

Getting ConnectionError which raises BadStatusLine error, even when IP is allocated:

http.client.BadStatusLine: {"id":384,"url":"http://192.168.122.209:8000/api/ipam/ip-addresses/384/","display":">[10.10.0.19/24](https://10.10.0.19/24)","family":{"value":4,"label":"IPv4"},"address":"[10.10.0.19/24](https://10.10.0.19/24)","vrf":{"id":1,"url":"http://192.168.122.209:8000/api/ipam/vrfs/1/","display":"admin","name":"admin","rd":null},"tenant":null,"status":{"value":"active","label":"Active"},"role":null,"assigned_object_type":null,"assigned_object_id":null,"assigned_object":null,"nat_inside":null,"nat_outside":[],"dns_name":"","description":"","tags":[],"custom_fields":{},"created":"2022-12-21T13:08:20.549255Z","last_updated":"2022-12-21T13:08:20.549284Z"}HTTP/1.1 201 Created

One more problem here is that the HTTP status goes after the response json.

@markkuleinio
Copy link
Contributor

pynetbox does not raise ConnectionErrors, it's some underlying module that's doing that.

Are you using the same pynetbox.api object (= the same requests.Session) in all those threads? I'm not a Python threading expert but I'm thinking if that could cause the responses to get messed up. See also: psf/requests#2766

@Yuliya-H
Copy link
Author

Yes , indeed I'm using one Session. I will try to separate and test this way, thanks

@Yuliya-H
Copy link
Author

Everything worked OK when using separate Sessions.

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

2 participants