SecureBlackbox 2020 Python Edition

Questions / Feedback?

async_mode Property

Controls the SSH clients mode of work.

Syntax

def get_async_mode() -> bool: ...
def set_async_mode(value: bool) -> None: ...

async_mode = property(get_async_mode, set_async_mode)

Default Value

FALSE

Remarks

This property defines the way in which the class communicates with the application/user code. async_mode set to false makes the component use synchronous single-thread approach. Synchronous mode is generally simpler to integrate and use, but please keep in mind that the calls like connect, receive or send_bytes may block until their execution completes. In asyncronous mode all operations return immediately, but more care should be taken about handling them in your code properly.

Here are a few highlights of each mode.

Synchronous mode:

  • All operations are performed within the caller thread context
  • Operations like connect or send_bytes may block
  • Use poll to check for the availability of data before reading it out with receive or receive_bytes
  • Return of a call guarantees completion of the operation
  • Connection errors are reported straight from the methods via exceptions

Asynchronous mode:

  • All operations are performed in a separate thread (and so are the event calls!)
  • Methods like send return immediately
  • Use on_data_sent and on_data_received events to be notified about actual data transmissions
  • Return of call only marks the beginning of the operation and does not guarantee its successful completion
  • Connection errors are reported via on_error event, often followed by on_disconnect.

Please note that this is a very important and sensitive property, which has a wide-scale effect on the way the SSH client works and co-operates with the application. Depending on the value assigned to this setting you may need to work with the component very differently.

When setting this property to true, please make sure that your code is prepared to handle events coming from the context of a different thread.

Copyright (c) 2022 /n software inc. - All rights reserved.
SecureBlackbox 2020 Python Edition - Version 20.0 [Build 8154]