Infinite recursion on ligo.gracedb.client.GraceDBClient.close method
Context
My understanding is that a requests.Session
should be exited using the .close()
method or be used within a with
context.
I'm currently using the ligo.gracedb.rest.GraceDb
class which ultimately inherits from ligo.gracedb.client.GraceDBClient
and therefore requests.Session
.
However, when this is called the ligo.gracedb.client.GraceDBClient.close
method runs with infinite recursion.
The line with the error is: https://git.ligo.org/computing/gracedb/client/-/blob/master/ligo/gracedb/client.py#L254
There is also a comment above this method that may or may not be related to solving this issue.
Code
I am using ligo-gracedb
v2.7.5 installed via conda-forge.
Minimal pseudocode to reproduce this error is below:
EDIT: The actual calls I used on the GraceDB client have been removed. It is sufficient to reproduce the error just by instantiating the GraceDB client and then trying to close it.
from ligo.gracedb.rest import GraceDb
with GraceDb(service_url="https://gracedb-playground.ligo.org/api/") as client:
pass
OR
from ligo.gracedb.rest import GraceDb
client = GraceDb(service_url="https://gracedb-playground.ligo.org/api/")
client.close()
Error Traceback is:
Traceback (most recent call last):
File "/home/daniel/spiir-dev/test_igwn_alert.py", line 43, in <module>
print(response)
File "/home/daniel/miniconda3/envs/spiir-dev/lib/python3.9/site-packages/ligo/gracedb/client.py", line 262, in __exit__
self.close()
File "/home/daniel/miniconda3/envs/spiir-dev/lib/python3.9/site-packages/ligo/gracedb/client.py", line 255, in close
self.close()
File "/home/daniel/miniconda3/envs/spiir-dev/lib/python3.9/site-packages/ligo/gracedb/client.py", line 255, in close
self.close()
File "/home/daniel/miniconda3/envs/spiir-dev/lib/python3.9/site-packages/ligo/gracedb/client.py", line 255, in close
self.close()
[Previous line repeated 995 more times]
RecursionError: maximum recursion depth exceeded
Potential Solution
If the self.close()
call is meant to be closing the requests.Session
class, should this instead be defined as:
#L254
def close(self):
super().close()
When I make this change no errors are returned. I have not otherwise formally tested this fix any further.