Skip to content

Commit

Permalink
Fixed builtin function scheduling on PyPY
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Nov 11, 2023
1 parent 1ecb343 commit db9b7e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/apscheduler/_schedulers/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,11 @@ async def add_schedule(
if ismethod(func_or_task_id):
args = (func_or_task_id.__self__,) + args
func_or_task_id = func_or_task_id.__func__
elif isbuiltin(func_or_task_id) and hasattr(func_or_task_id, "__self__"):
elif (
isbuiltin(func_or_task_id)
and func_or_task_id.__self__ is not None
and not ismodule(func_or_task_id.__self__)
):
args = (func_or_task_id.__self__,) + args
method_class = type(func_or_task_id.__self__)
func_or_task_id = getattr(method_class, func_or_task_id.__name__)
Expand Down Expand Up @@ -505,7 +509,11 @@ async def add_job(
if ismethod(func_or_task_id):
args = (func_or_task_id.__self__,) + args
func_or_task_id = func_or_task_id.__func__
elif isbuiltin(func_or_task_id) and not ismodule(func_or_task_id.__self__):
elif (
isbuiltin(func_or_task_id)
and func_or_task_id.__self__ is not None
and not ismodule(func_or_task_id.__self__)
):
args = (func_or_task_id.__self__,) + args
method_class = type(func_or_task_id.__self__)
func_or_task_id = getattr(method_class, func_or_task_id.__name__)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ def test_uwsgi_threads_error(self, monkeypatch: MonkeyPatch) -> None:
):
Scheduler().start_in_background()

@pytest.mark.skipif(
platform.python_implementation() != "CPython",
reason="May not work on other Python implementations",
)
def test_uwsgi_threads_error_subprocess(self) -> None:
prefix = ".exe" if platform.platform() == "Windows" else ""
uwsgi_path = Path(sysconfig.get_path("scripts")) / f"uwsgi{prefix}"
Expand Down

0 comments on commit db9b7e8

Please sign in to comment.