Skip to content

Commit ddeef41

Browse files
committed
make SpallocJob a contextlib.AbstractContextManager
1 parent 6a501ae commit ddeef41

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spinnman/spalloc/spalloc_job.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from contextlib import AbstractContextManager
1516
from types import TracebackType
1617
from typing import Dict, Mapping, Optional, Tuple, Type
1718
from typing_extensions import Literal, Self
1819

19-
from spinn_utilities.abstract_base import AbstractBase, abstractmethod
20+
from spinn_utilities.abstract_base import abstractmethod
2021
from spinnman.constants import SCP_SCAMP_PORT
2122
from spinnman.transceiver.transceiver import Transceiver
2223
from spinnman.connections.udp_packet_connections import UDPConnection
@@ -27,7 +28,7 @@
2728
from .spalloc_scp_connection import SpallocSCPConnection
2829

2930

30-
class SpallocJob(object, metaclass=AbstractBase):
31+
class SpallocJob(AbstractContextManager):
3132
"""
3233
Represents a job in Spalloc.
3334
@@ -216,8 +217,9 @@ def __enter__(self) -> Self:
216217
"""
217218
return self
218219

219-
def __exit__(self, exc_type: Optional[Type], exc_value: Exception,
220-
exc_tb: TracebackType) -> Literal[False]:
220+
def __exit__(self, exc_type: Optional[Type],
221+
exc_value: Optional[BaseException],
222+
exc_tb: Optional[TracebackType]) -> Literal[False]:
221223
"""
222224
Handle exceptions by killing the job and logging the exception in the
223225
job's destroy reason.

0 commit comments

Comments
 (0)