[DMC-873] Explicit context destructor for gfal2 python bindings Created: 05/Aug/16  Updated: 06/Feb/17  Resolved: 05/Aug/16

Status: Closed
Project: DMC - Development
Component/s: gfal2 python
Affects Version/s: None
Fix Version/s: gfal2-python 1.9.0
Security Level: Public Data (This ticket is visible to anyone on the internet and will be indexed by search engines)

Type: Improvement Priority: Major
Reporter: Marcel Rieger Assignee: Alejandro Alvarez Ayllon
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Component Watchers:

 Description   

Hi Alejandro,

we experienced an "issue" when using the gfal2 python bindings with the gsiftp:// protocol. However, this does not concern the gridftp-plugin but rather the python binding code itself.

When a context is used to execute a command that involves gsiftp://, a ftp connection is opened and kept alive as long as the context (or more precisely, the C++-library-based context instance ("C-context")) exists. The Py-context has no explicit destructor _del_ that invokes the C-context destructor, so the actual destruction, and thus, the closing of open ftp connections only takes place when the Py-context instance is garbage-collected. Potentially, this means that you cannot close connections manually unless you keep track of all references to that Py-context instance which can be quite difficult in more complex use-cases.

I would propose to add an explicit destructor in order to improve the control over open ftp connections.

Thanks for considering this feature request.



 Comments   
Comment by Alejandro Alvarez Ayllon [ 05/Aug/16 ]

Hi,

Thanks for the ticket. We'll do it for the next version.

Comment by Alejandro Alvarez Ayllon [ 05/Aug/16 ]

Would something like ctx.free() work for you?

Comment by Marcel Rieger [ 05/Aug/16 ]

Yes, ctx.free() this would work!

Comment by GitLab service [ 05/Aug/16 ]

Alejandro Alvarez Ayllon mentioned this issue in a commit of dmc/gfal2-bindings:
'DMC-873: Add context.free() to free resources'

Comment by Alejandro Alvarez Ayllon [ 05/Aug/16 ]

I have called it .free() at the end, since .release() was already in use for releasing files on a bring online storage.

After calling .free(), any other method (including free) will raise an exception like

gfal2.GError: gfal2 context has been freed

Cheers.

Comment by Clockwork Droid [ 05/Aug/16 ]

SUCCESS: Integrated in Jenkins build (devel) gfal2-python #29 (See https://jenkins.cern.ch/fts-dmc/job/(devel)%20gfal2-python/29/)
DMC-873: Add context.free() to free resources (alejandro.alvarez.ayllon: rev 627567ee0d7200d759076c48da8e1e21060d683c)

Comment by Marcel Rieger [ 05/Aug/16 ]

Cool, thanks!

Comment by GitLab service [ 06/Feb/17 ]

Alejandro Alvarez Ayllon mentioned this issue in a commit of dmc/gfal2-bindings:
'DMC-873: Add context.free() to free resources'

Generated at Tue Dec 12 20:53:05 CET 2017 using JIRA 7.3.8#73019-sha1:94e8771b8094eef96c119ec22b8e8868d286fa88.