Skip to content

Commit

Permalink
refactor(core): drop deprecrated gevent support (#2209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrabug authored Jul 12, 2023
1 parent 1ec477d commit 87088a9
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 68 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions docs/dev-guide/the-py3-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion docs/user-guide/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions py3status/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 0 additions & 7 deletions py3status/argparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 0 additions & 22 deletions py3status/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"]))
Expand Down
1 change: 0 additions & 1 deletion py3status/module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def __init__(self, config):
self.lock = Event()
self.output_modules = {}
self.running = True
self.is_gevent = False

self.lock.set()

Expand Down
4 changes: 0 additions & 4 deletions py3status/modules/kdeconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions py3status/modules/mpris.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] = {}
Expand Down
11 changes: 1 addition & 10 deletions py3status/py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}")
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 87088a9

Please sign in to comment.