Blocking Web-Frontend

#1

Hi,

I’m just evaluating crossbar.io.

I have setup a small Dashboard-Frontend that shows the status of calculations on the system.
The Front-End can trigger to capture an image. Calcluations are made on the image. The results are published and send with LoRa.

I use PubSub to share information and trigger new events.

There are 3 components:

  • Capture an image
  • make calculations on the image
  • send the result via LoRa

The Dashboard is showing the status of the 3 modules (blinking lights if heartbeat received).

But If I press the capture button. The Front-End is not updated until the last message (from LoRa) is published.

The source code can be found here:

https://github.com/busino/cb_test.git

I’m absolute beginner in async-programming. Perhaps there is a blocking call somewhere or the logic is absolutly wrong.

Thanks for any hints.

Raphael

0 Likes

#2

Hi Raphael,

Hi,

I'm just evaluating crossbar.io.

I have setup a small Dashboard-Frontend that shows the status of
calculations on the system.
The Front-End can trigger to capture an image. Calcluations are made on the
image. The results are published and send with LoRa.

I use PubSub to share information and trigger new events.

There are 3 components:
* Capture an image
* make calculations on the image
* send the result via LoRa

The Dashboard is showing the status of the 3 modules (blinking lights if
heartbeat received).

But If I press the capture button. The Front-End is not updated until the
`last` message (from LoRa) is published.

The source code can be found here:

https://github.com/busino/cb_test.git

I'm absolute beginner in async-programming. Perhaps there is a blocking
call somewhere or the logic is absolutly wrong.

The Python stdlib time.sleep is blocking the reactor:

https://github.com/busino/cb_test/blob/master/calculate_twisted.py#L30

A non-blocking sleep can be done like this:

from autobahn.twisted.util import sleep

@inlineCallbacks
def foo():
   for i in range(10):
      print(i)
      yield sleep(1)

Cheers,
/Tobias

···

Am 22.12.2017 um 12:01 schrieb raffs walk:

Thanks for any hints.

Raphael

0 Likes

#3

Hi Tobias,

Thanks for the reply.

I'm not sure if the `sleep` is really the blocker. If I run all the components from the command-line. Nothing is blocked.

Then I have changed all the code from twisted to asyncio (std libs are prefered).

But unfortunately the different components cannot be run from crossbar.

I'll update the example project to track what's the issue and how to go forward.

Raphael

···

On 2018-01-01 13:33, Tobias Oberstein wrote:

Hi Raphael,

Am 22.12.2017 um 12:01 schrieb raffs walk:

Hi,

I'm just evaluating crossbar.io.

I have setup a small Dashboard-Frontend that shows the status of
calculations on the system.
The Front-End can trigger to capture an image. Calcluations are made on the
image. The results are published and send with LoRa.

I use PubSub to share information and trigger new events.

There are 3 components:
  * Capture an image
  * make calculations on the image
  * send the result via LoRa

The Dashboard is showing the status of the 3 modules (blinking lights if
heartbeat received).

But If I press the capture button. The Front-End is not updated until the
`last` message (from LoRa) is published.

The source code can be found here:

https://github.com/busino/cb_test.git

I'm absolute beginner in async-programming. Perhaps there is a blocking
call somewhere or the logic is absolutly wrong.

The Python stdlib time.sleep is blocking the reactor:

https://github.com/busino/cb_test/blob/master/calculate_twisted.py#L30

A non-blocking sleep can be done like this:

from autobahn.twisted.util import sleep

@inlineCallbacks
def foo():
    for i in range(10):
       print(i)
       yield sleep(1)

Cheers,
/Tobias

Thanks for any hints.

Raphael

0 Likes

#4

I'm not sure if the `sleep` is really the blocker. If I run all the

well, I am.

time.sleep _is_ blocking, believe me;)

0 Likes