Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test macOS #92

Merged
merged 9 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-latest]
os: [ubuntu-20.04, windows-latest, macos-11]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this for now, until everything is properly tested

python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
Expand All @@ -40,4 +40,6 @@ jobs:
- name: Test with pytest
timeout-minutes: 30
run: |
# mpire needs a lot of file descriptors, too many for macOS' default settings
ulimit -n 5000
pytest -v -o log_cli=true -s
14 changes: 10 additions & 4 deletions mpire/comms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import collections
import gc
import multiprocessing as mp
import queue
import threading
Expand Down Expand Up @@ -231,7 +232,8 @@ def clear_progress_bar_shutdown(self) -> None:
"""
Clears the progress bar shutdown signal
"""
self._progress_bar_shutdown.clear()
if self._progress_bar_shutdown is not None:
self._progress_bar_shutdown.clear()

def signal_progress_bar_complete(self) -> None:
"""
Expand All @@ -243,13 +245,15 @@ def clear_progress_bar_complete(self) -> None:
"""
Clear that the progress bar is complete
"""
self._progress_bar_complete.clear()
if self._progress_bar_complete is not None:
self._progress_bar_complete.clear()

def wait_until_progress_bar_is_complete(self) -> None:
"""
Waits until the progress bar is completed
"""
self._progress_bar_complete.wait()
if self._progress_bar_complete is not None:
self._progress_bar_complete.wait()

################
# Order modifiers
Expand Down Expand Up @@ -635,6 +639,8 @@ def drain_results_queue_terminate_worker(self, dont_wait_event: threading.Event)
except (queue.Empty, OSError):
if got_results:
dont_wait_event.set()
# Force collection of semaphore objects
gc.collect()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add TODO that this still needs a proper fix, same for the other gc.collect


def drain_queues(self) -> None:
"""
Expand All @@ -656,7 +662,7 @@ def drain_and_join_queue(self, q: mp.JoinableQueue, join: bool = True) -> None:
if RUNNING_WINDOWS:
self._drain_and_join_queue(q, join)
else:
process = mp.Process(target=self._drain_and_join_queue, args=(q, join))
process = self.ctx.Process(target=self._drain_and_join_queue, args=(q, join))
process.start()
process.join(timeout=5)
if process.is_alive():
Expand Down
3 changes: 3 additions & 0 deletions mpire/pool.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import gc
import logging
import os
import queue
Expand Down Expand Up @@ -999,6 +1000,8 @@ def terminate(self) -> None:
send a sigkill.
"""
if not self._workers:
# Force collection of semaphore objects
gc.collect()
return

# Set exception thrown so workers know to stop fetching new tasks
Expand Down