Skip to content

Commit

Permalink
Rename project to graceful_shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
o-strokachuk committed Jan 16, 2023
1 parent ead435b commit 7faea8d
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 34 deletions.
18 changes: 9 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
|License| |Release| |Supported versions| |Docs| |Contact| |Blog|

gracefull-shutdown-py
graceful-shutdown-py
=====================

Helps to support gracefull shutdown for your python application.
Helps to support graceful shutdown for your python application.

Example of usage
----------------
Simple
^^^^^^
.. code:: python
from gracefull_shutdown import ExitSignalHandler
from graceful_shutdown import ExitSignalHandler
shutdown = ExitSignalHandler()
while not shutdown.triggered:
sleep(1)
.. |Release| image:: https://img.shields.io/github/release/zifter/gracefull-shutdown-py.svg
:target: https://github.com/zifter/gracefull-shutdown-py/releases
.. |Supported versions| image:: https://img.shields.io/pypi/pyversions/gracefull-shutdown-py.svg
:target: https://pypi.org/project/gracefull-shutdown-py/
.. |Release| image:: https://img.shields.io/github/release/zifter/graceful-shutdown-py.svg
:target: https://github.com/zifter/graceful-shutdown-py/releases
.. |Supported versions| image:: https://img.shields.io/pypi/pyversions/graceful-shutdown-py.svg
:target: https://pypi.org/project/graceful-shutdown-py/
.. |Contact| image:: https://img.shields.io/badge/telegram-write%20me-blue.svg
:target: https://t.me/zifter
.. |Blog| image:: https://img.shields.io/badge/site-my%20blog-yellow.svg
:target: https://zifter.github.io/
.. |License| image:: https://img.shields.io/badge/License-MIT-yellow.svg
:target: https://opensource.org/licenses/MIT
.. |Docs| image:: https://readthedocs.org/projects/gracefull-shutdown-py/badge/?version=latest&style=flat
:target: https://gracefull-shutdown-py.readthedocs.io/en/latest/
.. |Docs| image:: https://readthedocs.org/projects/graceful-shutdown-py/badge/?version=latest&style=flat
:target: https://graceful-shutdown-py.readthedocs.io/en/latest/

4 changes: 2 additions & 2 deletions docs/source/api-docs/api-docs-index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gracefull shutdown
graceful shutdown
==============

.. automodule:: gracefull_shutdown
.. automodule:: graceful_shutdown
:members:

.. toctree::
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to gracefull-shutdown-py's documentation!
Welcome to graceful-shutdown-py's documentation!
=====================================================================
.. include:: ../../README.rst

Expand Down
4 changes: 2 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pytest==6.2.1
pytest-cov==2.10.1
pytest==6.2.5
pytest-cov==3.0.0
14 changes: 7 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c

[metadata]
name = gracefull-shutdown-py
version = 0.2.2
name = graceful-shutdown-py
version = 0.3.0
author = Aleh Strakachuk
author_email = [email protected]
home-page = https://github.com/zifter/gracefull-shutdown-py
description = attr: gracefull_shutdown.__doc__
home-page = https://github.com/zifter/graceful-shutdown-py
description = attr: graceful_shutdown.__doc__
long-description = file: README.rst
long_description_content_type = text/x-rst
license = MIT
license-file = LICENSE
platform = any
keywords = gracefull,shutdown
keywords = graceful,shutdown
classifiers =
Development Status :: 5 - Production/Stable
License :: OSI Approved :: MIT License
Expand All @@ -31,10 +31,10 @@ zip_safe = false
include_package_data = true
python_requires = >= 3.5
package_dir =
gracefull_shutdown=src/gracefull_shutdown
graceful_shutdown=src/graceful_shutdown
tests=src/tests
packages =
gracefull_shutdown
graceful_shutdown
test_suite = tests
setup_requires =
setuptools >=30.3.0 # minimal version for `setup.cfg`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Package with gracefull shutdown functionality
Package with graceful shutdown functionality
"""
import signal
from logging import getLogger

_logger = getLogger("gracefull-shutdown")
_logger = getLogger("graceful-shutdown")


class ExitSignalHandler:
Expand All @@ -18,10 +18,10 @@ def __init__(self):
"""
self._triggered: bool = False

signal.signal(signal.SIGINT, self._exit_gracefully)
signal.signal(signal.SIGTERM, self._exit_gracefully)
signal.signal(signal.SIGINT, self.exit_gracefuly)
signal.signal(signal.SIGTERM, self.exit_gracefuly)

def _exit_gracefully(self, _signum, _frame):
def exit_gracefuly(self, _signum, _frame):
"""
Signal handler
"""
Expand All @@ -44,6 +44,12 @@ def triggered(self) -> bool:
"""
return self._triggered

def __bool__(self) -> bool:
"""
Cast to bool
"""
return self.triggered


__all__ = [
"ExitSignalHandler",
Expand Down
Empty file added src/tests/__init__.py
Empty file.
17 changes: 15 additions & 2 deletions src/tests/gracefull_shutdown_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
"""
Tests for gracefull shutdown
Tests for graceful shutdown
"""
from gracefull_shutdown import ExitSignalHandler
from graceful_shutdown import ExitSignalHandler


def test_trigger_like_signal_ok():
"""
Check correct creation and trigger as signal handler
"""
shutdown = ExitSignalHandler()

assert shutdown.triggered is False

shutdown.exit_gracefuly(None, None)

assert shutdown.triggered is True


def test_trigger_ok():
Expand Down
11 changes: 5 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ deps = black==22.3.0
commands = black --check src/

[testenv:coverage_report]
passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_* APPVEYOR APPVEYOR_*
deps =
coverage==5.0.2
coverage==6.4.3
codecov==2.0.15
commands =
coverage html
coverage report --include="src/*" --fail-under=100 -m
coverage report --include="src/graceful_shutdown/*" --fail-under=99 -m
coverage report --include="src/tests/*" --fail-under=100 -m
coverage xml
codecov -f coverage.xml --token=2455dcfa-f9fc-4b3a-b94d-9765afe87f0f

[testenv:gen_docs]
skip_install = True
Expand All @@ -82,7 +81,7 @@ commands =
[testenv:test_venv]
skip_install = True
commands =
pip install --extra-index-url https://pypi.org/simple -i https://test.pypi.org/simple/ gracefull-shutdown-py
pip install --extra-index-url https://pypi.org/simple -i https://test.pypi.org/simple/ graceful-shutdown-py

[testenv:pypi_upload]
deps =
Expand All @@ -100,7 +99,7 @@ commands =
skip_install = True
deps =
commands =
pip install gracefull-shutdown-py
pip install graceful-shutdown-py


########
Expand Down

0 comments on commit 7faea8d

Please sign in to comment.