broken pipe error gnupg sigterm signal

207 vistas
Ir al primer mensaje no leído

spidernello66

no leída,
30 jun 2022, 5:47:32 a.m.30/6/22
para python-gnupg
Hi everyone, 

I have a singular issue to describe. I' am using python-gnupg 0.4.6. I have currently implemented a solution using the python 'signal' library using python 3.6 to be able to catch a SIGTERM signal and gracefully stop my application.

The application I am using runs in an infinite loop, once the SIGTERM is being sent, there is a handler than catches the SIGTERM signal and set the bool flag of the loop to False which exits the loop after completing the whole process, gracefully stopping the application with exit-code 0. 

Within my application, I am calling the python-gnupg library to perform encryption and decryption operations on various files.

In my tests, I have tried to send a SIGTERM signal to shutdown the application while performing a decryption operation, however, the gpg process taking care of the mentioned task immediately exited without waiting to complete the given task provoking a decryption error.

This the error occurred:

"Error sending data Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/gnupg.py", line 156, in _copy_data outstream.write(data) BrokenPipeError: [Errno 32] Broken pipe Exception occurred while closing: ignored Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/gnupg.py", line 165, in _copy_data outstream.close() BrokenPipeError: [Errno 32] Broken pipe gpg returned a non-zero error code: -15"

I am trying to figure out the best approach how to fix this issue. Any idea? Thanks!

Vinay Sajip

no leída,
30 jun 2022, 6:02:29 a.m.30/6/22
para python-gnupg
I'm not sure this is specific to python-gnupg - it seems to be a more generic problem. AFAIK SIGTERM isn't propagated to child processes, do you catch and process SIGPIPE as well? From what I can tell, the exception is occurring at the end of the copy loop when trying to close the stream being copied to.

nello

no leída,
30 jun 2022, 9:25:47 a.m.30/6/22
para python-gnupg
Hi Vinay, thanks for your reply! I am catching the SIGPIPE, however, the exception still occurs. What I have noticed is that the decrypted file is corrupted and the copy loop does not complete, it actually stops performing any operation in the middle of the process leaving the file in a 'middle' state. When the exception occurs the gpg subprocess taking care of the decryption process exits immeadtely. this is the actual process that is being terminated immediately provoking the exception

test+ 26724 26695 99 11:07 ? 00:00:03 gpg --status-fd 2 --no-tty --no-verbose --fixed-list-mode --batch --

If I keep the operation going without sending a termination signal in the middle of the decryption process the application acks to have received the termination signal, but still waits to complete all the rest of the tasks before exiting gracefully. it seems to me that something is happening within the copy process but cant seem to find a way how to fix this

Vinay Sajip

no leída,
30 jun 2022, 5:53:19 p.m.30/6/22
para python-gnupg
What is sending SIGTERM to the gpg child process? Or if not because of SIGTERM, why is it terminating prematurely?

Antonio Cascella

no leída,
11 jul 2022, 3:49:39 p.m.11/7/22
para python-gnupg
Hi Vinaj, thanks for taking some more time to answer my question. I was out for a while and could not update the thread, however I seem to have found the issue. It resides in the supervisor layer, i had to re work my signaling logic in order to avoid the issue I previously described. Have a great day!

--

---
You received this message because you are subscribed to a topic in the Google Groups "python-gnupg" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-gnupg/Y93uy4HX7bI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-gnupg...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/python-gnupg/5e456102-0321-45e5-842d-4e686d8701d3n%40googlegroups.com.

Vinay Sajip

no leída,
11 jul 2022, 6:12:52 p.m.11/7/22
para python-gnupg
Thanks for the update. I hope the information will help others!
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos