platformio / platformio/platformio-core

`pio remote device list` takes over 7 minutes to complete after an agent drops from network

Open
#3,575 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

remote
Dominant language
Python
Stars
9.5k
Forks
905
Avg merge
2d 13h
Merged PRs (30d)
2

Description

Configuration

Operating system: 16.04 LTS

PlatformIO Version (platformio --version): PlatformIO, version 4.3.4

Description of problem

In normal operation, running pio remote device list takes about 2 seconds. However, if one of the agents is dropped from the network (e.g. loses internet connection, or suffers a power outage), suddenly pio remote device list blocks for over 7 minutes!

Steps to Reproduce
  1. On 2 remote computers:
    1. Log in to your account with pio account login
    2. Then start agents with pio remote agent start
  2. On a local computer:
    1. Log in to your account with pio account login
    2. Execute pio remote device list
    3. Verify that the response shows 2 remote agents (and also some devices which will depend on your remote computer hardware, unimportant)
  3. Disconnect one of the remote computers from the internet
  4. On the local computer execute pio remote device list again
Actual Results

Results take extremely long time to arrive.
There is also a red error message at the top:

[Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
]

The results are correct despite the error, though. They show the one remaining agent and its devices.

Expected Results

Results should be displayed within a few seconds and without the error message.

Additional info

pio remote agent list appears to not suffer from this problem, although it continues to show the dropped agent for roughly the same duration of time (I measured 5 minutes).

Showing the issue using time

cabox@Ubuntu:~/workspace$ time pio remote device list
Agent Prgm-de32
===============
/dev/ttyAMA0
------------
Hardware ID: 3f201000.serial
Description: ttyAMA0

Agent Prgm-61da
===============
/dev/ttyUSB0
------------
Hardware ID: USB VID:PID=10C4:EA60 SER=0001 LOCATION=1-1
Description: CP2102 USB to UART Bridge Controller

/dev/ttyAMA0
------------
Hardware ID: 20201000.serial
Description: ttyAMA0

Agent Prgm-1609
===============
/dev/ttyAMA0
------------
Hardware ID: 20201000.serial
Description: ttyAMA0

Agent Prgm-4cea
===============
/dev/ttyAMA0
------------
Hardware ID: 20201000.serial
Description: ttyAMA0


real    0m2.214s
user    0m0.504s
sys     0m0.079s

cabox@Ubuntu:~/workspace$ # DISCONNECTED DEVICE WITH "Prgm-1609" AGENT
cabox@Ubuntu:~/workspace$ # THEN RUNNING THE SAME COMMAND AGAIN:
cabox@Ubuntu:~/workspace$ time pio remote device list
[Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionDone'>: Connection was closed cleanly.
]
Agent Prgm-de32
===============
/dev/ttyAMA0
------------
Hardware ID: 3f201000.serial
Description: ttyAMA0

Agent Prgm-61da
===============
/dev/ttyUSB0
------------
Hardware ID: USB VID:PID=10C4:EA60 SER=0001 LOCATION=1-1
Description: CP2102 USB to UART Bridge Controller

/dev/ttyAMA0
------------
Hardware ID: 20201000.serial
Description: ttyAMA0

Agent Prgm-4cea
===============
/dev/ttyAMA0
------------
Hardware ID: 20201000.serial
Description: ttyAMA0


real    7m9.390s
user    0m0.534s
sys     0m0.085s

Note that the command took 2.2 seconds to run the first time and 7m9s the second time.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing pio remote device list with one remote agent disconnected, comparing its timing and output with the connected case. Trace the remote device-list and agent-connection handling; done means the command returns within a few seconds and does not print the reported connection error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.