Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/deepzoom/deepzoom_multiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
if os.name == 'nt':
_dll_path = os.getenv('OPENSLIDE_PATH')
if _dll_path is not None:
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined]
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
import openslide
else:
import openslide
Expand Down
2 changes: 1 addition & 1 deletion examples/deepzoom/deepzoom_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
if os.name == 'nt':
_dll_path = os.getenv('OPENSLIDE_PATH')
if _dll_path is not None:
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined]
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
import openslide
else:
import openslide
Expand Down
19 changes: 16 additions & 3 deletions examples/deepzoom/deepzoom_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
if os.name == 'nt':
_dll_path = os.getenv('OPENSLIDE_PATH')
if _dll_path is not None:
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined]
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
import openslide
else:
import openslide
Expand Down Expand Up @@ -382,6 +382,19 @@ def _shutdown(self) -> None:


if __name__ == '__main__':
try:
# Python 3.13+
available_cpus = os.process_cpu_count() # type: ignore[attr-defined]
except AttributeError:
try:
# Linux
available_cpus = len(
os.sched_getaffinity(0) # type: ignore[attr-defined,unused-ignore]
)
except AttributeError:
# default
available_cpus = 4

parser = ArgumentParser(usage='%(prog)s [options] <SLIDE>')
parser.add_argument(
'-B',
Expand Down Expand Up @@ -433,8 +446,8 @@ def _shutdown(self) -> None:
metavar='COUNT',
dest='workers',
type=int,
default=4,
help='number of worker processes to start [4]',
default=available_cpus,
help=f'number of worker processes to start [{available_cpus}]',
)
parser.add_argument(
'-o',
Expand Down
2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# environment.
_dll_path = os.getenv('OPENSLIDE_PATH')
if _dll_path is not None:
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined]
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
import openslide # noqa: F401 module-imported-but-unused


Expand Down
Loading