Comments (7)
Think this issue can be closed (see #44 merge)
from cdo-bindings.
hi!
I didn't get a notification, sorry. Could you use ctrl-D
? it works for me.
from cdo-bindings.
Hello! Sorry I must have missed your notification as well. No, crtl-D
doesn't work. Here is what the terminal output looks like when I try to crtl-C
:
^Ccaught signal <cdo.Cdo object at 0x7f9c262dde10> 2 <frame object at 0x2307e88
from cdo-bindings.
I work on a new cdo.py release 2.0 with a new interface. Will take of this for 2.0 then.
thx for your patience
from cdo-bindings.
No problem! Thank you for addressing the issue.
from cdo-bindings.
Think I duplicated this issue in #43. Also here's a possible workaround (although I can't test it -- seems the current master branch does not work right now). Inside Cdo.__init__
I replace the signal definitions with this:
# handling different exits from interactive sessions {{{
# python3 has threading.main_thread(), but python2 doesn't
import functools
if sys.version_info[0] == 2 \
or threading.current_thread() is threading.main_thread():
sigint_default = signal.getsignal(signal.SIGINT)
sigterm_default = signal.getsignal(signal.SIGTERM)
sigsegv_default = signal.getsignal(signal.SIGSEGV)
sigint = functools.partial(self.__catch__, default=sigint_default)
sigterm = functools.partial(self.__catch__, default=sigterm_default)
sigsegv = functools.partial(self.__catch__, default=sigsegv_default)
signal.signal(signal.SIGINT, sigint)
signal.signal(signal.SIGTERM, sigterm)
signal.signal(signal.SIGSEGV, sigsegv)
and then replace Cdo.__catch__
with the following lines that throw the default handler after removing tempfiles:
def __catch__(self, signum, frame, default=None):
self.tempStore.__del__()
if callable(default):
default()
else:
print("caught signal", self, signum, frame)
from cdo-bindings.
Ok while I couldn't test the above solution on the master branch, here's a simple workaround that succeeds with the latest stable version. I just call cdo = _init_cdo()
instead of cdo = Cdo()
in the python script or interactive session:
import signal
import threading
from cdo import Cdo
def _cdo_handler(cdo, handler):
def _handle_signal(*args, **kwargs):
cdo.tempStore.__del__()
handler(*args, **kwargs)
return _handle_signal
def _init_cdo():
sigint = signal.getsignal(signal.SIGINT)
sigterm = signal.getsignal(signal.SIGTERM)
sigsegv = signal.getsignal(signal.SIGSEGV)
cdo = Cdo()
signal.signal(signal.SIGINT, _cdo_handler(cdo, sigint))
signal.signal(signal.SIGTERM, _cdo_handler(cdo, sigterm))
signal.signal(signal.SIGSEGV, _cdo_handler(cdo, sigsegv))
return cdo
from cdo-bindings.
Related Issues (20)
- temp files aren't deleted HOT 21
- Error loading netCDF4 after installing CDO HOT 7
- Support converting .dat file to .nc file HOT 8
- Apply new syntax for calls with mutiple inputs HOT 24
- Segmentation fault when using bindings HOT 1
- Feature request: PyCDO for/from Bash HOT 3
- New release on PyPI HOT 5
- cdo=Cdo() #####FileNotFoundError: [WinError 2] HOT 3
- Mention how the bindings are supported in python-cdo package from conda-forge HOT 2
- threaded cdo HOT 6
- help(cdo.<operator name>) does not work anymore
- cdo-bindings fail with cdo2.0.0 HOT 2
- `muldpm` was `muldpy` in conda cdo HOT 1
- Hi sir,I am trying to install python-cdo by using "conda create -n cdo_test python=3 cdo python-cdo" and it shows error. HOT 2
- Python binding captures "kill" and "KeyboardInterrupt" signals in all processes after initialization HOT 4
- Hard coded `-s` HOT 2
- Can not initialize Cdo object for CDO version 1.9.10 HOT 5
- clarify license of `cdo-bindings` HOT 3
- Cannot initialize with specified cdopath HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cdo-bindings.