Print

Print


@adriansev : I had a look into the issue, in Python `SIGINT` is by default translated into a `KeyboardInterrupt`, if you ignore this exception `SIGINT` will have no effect on you.

You can replace the default signal handler for `SIGINT` with `signal.signal()`, now the handler you provide will be called with two arguments, see: https://docs.python.org/3/library/signal.html#signal.signal

> The handler is called with two arguments: the signal number and the current stack frame (None or a frame object; for a description of frame objects, see the description in the type hierarchy or see the attribute descriptions in the inspect module).

I suppose that's why your script does not work as your handler expects 3 arguments:
` def catch(self, signum, frame):`

I tested it with the following code snippet:

```
import signal
from XRootD import client

interrupted=False
def handleSigInt( signalNumber, frame ):
  global interrupted
  interrupted=True
signal.signal( signal.SIGINT, handleSigInt )

class MyCopyProgressHandler(client.utils.CopyProgressHandler):
  def should_cancel(self, jobId):
    if interrupted : print 'cancelling due to SIGINT'
    return interrupted

process = client.CopyProcess()
process.add_job( source='/path/to/1GB',
                 target='root://hostname//dir/1GB',
                 force=True)

print process.prepare()
handler = MyCopyProgressHandler()
print process.run( handler )[1]
```

and it works reasonably well.

Could you have a look and let me know if we can close this issue?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/xrootd/xrootd/issues/1170#issuecomment-610962582

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1