Skip to content

Commit

Permalink
Pass fd to faulthandler to avoid ResourceWarning.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikratio committed Oct 2, 2018
1 parent 5647e09 commit 3c0b39d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion rst/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ that is not the case.
* `SQLite <http://www.sqlite.org/>`_ version 3.7.0 or newer. SQLite
has to be installed as a *shared library* with development headers.

* `Python <http://www.python.org/>`_ 3.3.0 or newer. Make sure to also
* `Python <http://www.python.org/>`_ 3.5.0 or newer. Make sure to also
install the development headers.

* The following Python modules:
Expand Down
8 changes: 4 additions & 4 deletions src/s3ql/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ def unmount():
else:
if stdout_log_handler:
logging.getLogger().removeHandler(stdout_log_handler)
global crit_log_fh
crit_log_fh = open(os.path.join(options.cachedir, 'mount.s3ql_crit.log'), 'a')
faulthandler.enable(crit_log_fh)
faulthandler.register(signal.SIGUSR1, file=crit_log_fh)
crit_log_fd = os.open(os.path.join(options.cachedir, 'mount.s3ql_crit.log'),
flags=os.O_APPEND|os.O_CREAT|os.O_WRONLY, mode=0o644)
faulthandler.enable(crit_log_fd)
faulthandler.register(signal.SIGUSR1, file=crit_log_fd)
daemonize(options.cachedir)

mark_metadata_dirty(backend, cachepath, param)
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def pytest_configure(config):
warnings.simplefilter('default')

# Enable faulthandler
global faultlog_fh
faultlog_fh = open(os.path.join(basedir, 'tests', 'test_crit.log'), 'a')
faulthandler.enable(faultlog_fh)
faulthandler.register(signal.SIGUSR1, file=faultlog_fh)
faultlog_fd = os.open(os.path.join(basedir, 'test_crit.log'),
flags=os.O_APPEND|os.O_CREAT|os.O_WRONLY, mode=0o644)
faulthandler.enable(faultlog_fd)
faulthandler.register(signal.SIGUSR1, file=faultlog_fd)

# Configure logging. We don't set a default handler but rely on
# the catchlog pytest plugin.
Expand Down

0 comments on commit 3c0b39d

Please sign in to comment.