Skip to content

Commit

Permalink
target: add set_connection()
Browse files Browse the repository at this point in the history
Add a method to set the connection for the current thread within the
target. This method returns the connection that was previously set.
  • Loading branch information
setrofim committed Jan 23, 2020
1 parent 9661c6b commit 29438c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions devlib/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ def get_connection(self, timeout=None):
raise ValueError('Connection class not specified on Target creation.')
return self.conn_cls(timeout=timeout, **self.connection_settings) # pylint: disable=not-callable

def set_connection(self, conn):
tid = id(threading.current_thread())
old_conn = self._connections.get(tid)
self._connections[tid] = conn
return old_conn

def wait_boot_complete(self, timeout=10):
raise NotImplementedError()

Expand Down
7 changes: 7 additions & 0 deletions doc/target.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ Target
blocking operation (e.g. using ``background()``) while at the same
time doing something else in the same host-side thread.

.. method:: Target.set_connection(conn)

Set the Target's connection for the current thread to the one specified
(typically, one that has previously been returned by the call to
``get_connection``). Returns the old connection to the current thread -- it
is up to the coller to keep track of it and restore it if they wish.

.. method:: Target.setup([executables])

This will perform an initial one-time set up of a device for devlib
Expand Down

0 comments on commit 29438c8

Please sign in to comment.