Skip to content

Commit

Permalink
address PR comments, don't use self. in thread_manager. Some debug li…
Browse files Browse the repository at this point in the history
…nes to remove
  • Loading branch information
sanni-t committed Apr 21, 2021
1 parent b5cdd31 commit a0916f6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions api/src/opentrons/drivers/thermocycler/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,12 @@ def send(self, command, callback):
self._send_write_fd.write(b'c')

def close(self):
log.debug("Halting TCPoller")
log.info("===== Halting TCPoller")
self._halt_write_fd.write(b'q')

def __del__(self):
""" Clean up thread fifos"""
log.debug("Cleaning up thread fifos in TCPoller.")
log.info("===== Cleaning up thread fifos in TCPoller.")
try:
os.unlink(self._send_path)
except NameError:
Expand Down Expand Up @@ -381,7 +381,7 @@ def disconnect(self) -> 'Thermocycler':
if self.is_connected() or self._poller:
self._poller.close() # type: ignore
self._poller.join() # type: ignore
log.debug("TC poller stopped.")
log.info("===== TC poller stopped.")
self._poller = None
return self

Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/hardware_control/modules/tempdeck.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ async def _connect(self):
self._poller.start()

def cleanup(self) -> None:
if self._poller:
log.debug("Stopping tempdeck poller.")
if hasattr(self, '_poller') and self._poller:
log.info("===== Stopping tempdeck poller.")
self._poller.stop()

async def prep_for_update(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/hardware_control/thread_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def clean_up(self):
loop.call_soon_threadsafe(loop.stop)
except Exception:
pass
self._cached_modules = {}
object.__setattr__(self, '_cached_modules', {})
object.__getattribute__(self, '_thread').join()

def wrap_module(
Expand All @@ -199,7 +199,7 @@ def __getattribute__(self, attr_name):
# is necessary in order to allow the garbage collector to delete
# those objects from memory and cleanly stop all associated threads.
cached_mods = {
module: cached_mods.get(module, wrap(module)) for module in attr}
module: cached_mods.get(module) or wrap(module) for module in attr}
object.__setattr__(self, '_cached_modules', cached_mods)
return cached_mods.values()
elif attr_name == 'clean_up':
Expand Down
3 changes: 3 additions & 0 deletions api/tests/opentrons/hardware_control/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from opentrons.drivers.rpi_drivers.types import USBPort


# Freezes
async def test_get_modules_simulating():
import opentrons.hardware_control as hardware_control
mods = ['tempdeck', 'magdeck', 'thermocycler']
Expand Down Expand Up @@ -61,6 +62,7 @@ async def test_module_caching():
assert two_magdecks[1] is not two_magdecks[0]


# freezes
async def test_filtering_modules():
import opentrons.hardware_control as hardware_control
mods = [
Expand Down Expand Up @@ -178,6 +180,7 @@ async def mock_find_bossa_bootloader_port():
)


# freezes
async def test_get_bundled_fw(monkeypatch, tmpdir):
from opentrons.hardware_control import modules

Expand Down

0 comments on commit a0916f6

Please sign in to comment.