From 87088a9283d128f8f1f63d89acfcd10ab7d44e34 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Wed, 12 Jul 2023 09:11:32 +0200 Subject: [PATCH] refactor(core): drop deprecrated gevent support (#2209) --- CHANGELOG | 4 ++++ README.md | 1 - docs/dev-guide/the-py3-helper.md | 4 ---- docs/getting-started.md | 1 - docs/user-guide/installation.md | 1 - py3status/__init__.py | 10 ---------- py3status/argparsers.py | 7 ------- py3status/core.py | 22 ---------------------- py3status/module_test.py | 1 - py3status/modules/kdeconnector.py | 4 ---- py3status/modules/mpris.py | 4 ---- py3status/py3.py | 11 +---------- setup.py | 5 ++--- 13 files changed, 7 insertions(+), 68 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5cd94a5e13..d23683885a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +version 3.52 (2023-07-11) +* IMPORTANT: gevent support is now deprecated and removed +* core: drop gevent support + version 3.51 (2023-06-27) * NEW: thanks to Andreas Grapentin, py3status can now run in lots of other containers (tmux, term, dzen2, lemonbar...) * IMPORTANT: modules are moving away from the obsolete pydbus library diff --git a/README.md b/README.md index 538f45cecf..6b9cf3fddd 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,6 @@ You can see the help of py3status by issuing \`py3status -h\`: -c, --config FILE load config (default: /home/alexys/.i3/i3status.conf) -d, --debug enable debug logging in syslog and --log-file (default: False) - -g, --gevent enable gevent monkey patching (default: False) -i, --include PATH append additional user-defined module paths (default: None) -l, --log-file FILE enable logging to FILE (default: None) diff --git a/docs/dev-guide/the-py3-helper.md b/docs/dev-guide/the-py3-helper.md index f63e90b3f2..118da9597f 100644 --- a/docs/dev-guide/the-py3-helper.md +++ b/docs/dev-guide/the-py3-helper.md @@ -297,10 +297,6 @@ function is a helper for this second case. Check if item is a Composite and return True if it is. -### is_gevent() - -Checks if gevent monkey patching is enabled or not. - ### is_my_event(event) Checks if an event triggered belongs to the module receiving it. This diff --git a/docs/getting-started.md b/docs/getting-started.md index 8a0b512bad..6bc27c509b 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -57,7 +57,6 @@ optional arguments: -c, --config FILE load config (default: /home/alexys/.i3/i3status.conf) -d, --debug enable debug logging in syslog and --log-file (default: False) - -g, --gevent enable gevent monkey patching (default: False) -i, --include PATH append additional user-defined module paths (default: None) -l, --log-file FILE enable logging to FILE (default: None) diff --git a/docs/user-guide/installation.md b/docs/user-guide/installation.md index 41f21a1082..62c8c1f3c7 100644 --- a/docs/user-guide/installation.md +++ b/docs/user-guide/installation.md @@ -63,7 +63,6 @@ $ pip install py3status There are optional requirements that you could find useful: -- `py3status[gevent]` for gevent support. - `py3status[udev]` for udev support. Or if you want everything: diff --git a/py3status/__init__.py b/py3status/__init__.py index 29ec0caf60..0ce56a5b96 100755 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -13,16 +13,6 @@ def main(): from py3status.argparsers import parse_cli_args options = parse_cli_args() - # detect gevent option early because monkey patching should be done before - # everything else starts kicking - if options.gevent: - try: - from gevent import monkey - - monkey.patch_all() - except Exception: - # user will be notified when we start - pass from py3status.core import Py3statusWrapper diff --git a/py3status/argparsers.py b/py3status/argparsers.py index cccc64d6a4..f5d32ef798 100644 --- a/py3status/argparsers.py +++ b/py3status/argparsers.py @@ -88,13 +88,6 @@ def _format_action_invocation(self, action): action="store_true", help="enable debug logging in syslog or log file if --log-file option is passed", ) - parser.add_argument( - "-g", - "--gevent", - action="store_true", - dest="gevent", - help="enable gevent monkey patching", - ) parser.add_argument( "-i", "--include", diff --git a/py3status/core.py b/py3status/core.py index ab8bf9ec7b..2b52345c7a 100644 --- a/py3status/core.py +++ b/py3status/core.py @@ -424,23 +424,6 @@ def timeout_queue_process(self): if self.timeout_due is not None: return max(0, self.timeout_due - time.monotonic()) - def gevent_monkey_patch_report(self): - """ - Report effective gevent monkey patching on the logs. - """ - try: - import gevent.socket - import socket - - if gevent.socket.socket is socket.socket: - self.log("gevent monkey patching is active") - return True - else: - self.notify_user("gevent monkey patching failed.") - except ImportError: - self.notify_user("gevent is not installed, monkey patching failed.") - return False - def get_user_modules(self): """Mapping from module name to relevant objects. @@ -603,11 +586,6 @@ def setup(self): if self.config["debug"]: self.log(f"py3status started with config {self.config}") - if self.config["gevent"]: - self.is_gevent = self.gevent_monkey_patch_report() - else: - self.is_gevent = False - # read i3status.conf config_path = self.config["i3status_config_path"] self.log("config file: {}".format(self.config["i3status_config_path"])) diff --git a/py3status/module_test.py b/py3status/module_test.py index d0177bc441..d43187b58f 100644 --- a/py3status/module_test.py +++ b/py3status/module_test.py @@ -35,7 +35,6 @@ def __init__(self, config): self.lock = Event() self.output_modules = {} self.running = True - self.is_gevent = False self.lock.set() diff --git a/py3status/modules/kdeconnector.py b/py3status/modules/kdeconnector.py index d8e84c00a5..ecfd99b6bd 100644 --- a/py3status/modules/kdeconnector.py +++ b/py3status/modules/kdeconnector.py @@ -75,7 +75,6 @@ from gi.repository import GLib from pydbus import SessionBus -STRING_GEVENT = "this module does not work with gevent" SERVICE_BUS = "org.kde.kdeconnect" INTERFACE = SERVICE_BUS + ".device" INTERFACE_DAEMON = SERVICE_BUS + ".daemon" @@ -109,9 +108,6 @@ class Py3status: status_notif = " ✉" def post_config_hook(self): - if self.py3.is_gevent(): - raise Exception(STRING_GEVENT) - self._bat = None self._con = None self._dev = None diff --git a/py3status/modules/mpris.py b/py3status/modules/mpris.py index 7733e9d91f..f3264a5985 100644 --- a/py3status/modules/mpris.py +++ b/py3status/modules/mpris.py @@ -113,8 +113,6 @@ from mpris2.types import Metadata_Map from enum import IntEnum -STRING_GEVENT = "this module does not work with gevent" - class STATE(IntEnum): Playing = 0 @@ -389,8 +387,6 @@ class Py3status: state_stop = "\u25a1" def post_config_hook(self): - if self.py3.is_gevent(): - raise Exception(STRING_GEVENT) self._name_owner_change_match = None self._kill = False self._mpris_players: dict[Player] = {} diff --git a/py3status/py3.py b/py3status/py3.py index b7b94bd7c9..be2aba4701 100644 --- a/py3status/py3.py +++ b/py3status/py3.py @@ -11,6 +11,7 @@ from pprint import pformat from shutil import which from subprocess import Popen, PIPE, STDOUT +from time import sleep from uuid import uuid4 from py3status import exceptions @@ -420,12 +421,6 @@ def i3s_config(self): """ return self._i3s_config - def is_gevent(self): - """ - Checks if gevent monkey patching is enabled or not. - """ - return self._py3_wrapper.is_gevent - def is_my_event(self, event): """ Checks if an event triggered belongs to the module receiving it. This @@ -1310,10 +1305,6 @@ def get_http_response(): try: return get_http_response() except (self.RequestTimeout, self.RequestURLError): - if self.is_gevent(): - from gevent import sleep - else: - from time import sleep self.log(f"HTTP request retry {n}/{retry_times}") sleep(retry_wait) self.log(f"HTTP request retry {retry_times}/{retry_times}") diff --git a/setup.py b/setup.py index d4ecea36e3..0145e993b4 100755 --- a/setup.py +++ b/setup.py @@ -23,9 +23,8 @@ def read(fname): # extra requirements -req_gevent = ["gevent >= 1.1"] req_udev = ["pyudev >= 0.21.0"] -req_all = req_gevent + req_udev +req_all = req_udev setup( name="py3status", @@ -35,7 +34,7 @@ def read(fname): description="py3status: an extensible i3status wrapper written in python", long_description=read("README.md"), long_description_content_type="text/markdown", - extras_require={"all": req_all, "gevent": req_gevent, "udev": req_udev}, + extras_require={"all": req_all, "udev": req_udev}, url="https://github.com/ultrabug/py3status", download_url="https://github.com/ultrabug/py3status/tags", license="BSD",