robotpy / pynetworktables

Pure python implementation of the FRC NetworkTables protocol
Other
60 stars 30 forks source link

NT freeze when interacting with LabVIEW #110

Closed virtuald closed 4 years ago

virtuald commented 4 years ago

Reported from a user via email:

We have used your library PyNetworkTables on our raspberry 4, for vision processing purposes and  we've ran into some issues regarding to your library.

After examing the behaviour of the library, We discovered that sometimes, after ~32900 value sending, The NT server freezes. We need to declare:

  1. We used Raspi 4 and LabVIEW 2020
  2. We used all of the examples from ReadTheDocs and other sites and repos, and there are still freezing.
  3. The raspi and the RoboRio is still working, so there is no raspi or RoboRio freezing.
  4. We also run a special test: We sent values for the roborio and didn't do anything else(robot running, Vision process etc.)
  5. There is no CPU overflow/raspi RAM or CPU overflow or any other high usage of any other resources.

for example:

If you take the basic example from your ReadTheDocs and make a simple LabVIEW listener, we have found that after the ~32900 the library freezes.

We have tried to do so on every version from 2016-->2020 and this error accurs from 2017 and up. 2016 is obslete so we cannot use it operationally.

virtuald commented 4 years ago

Tested this with a python client -> python server, sequence number rollover seems to be handled fine.

Client:

#!/usr/bin/env python3

import sys
import time
from networktables import NetworkTables

# To see messages from networktables, you must setup logging
import logging

logging.basicConfig(level=logging.DEBUG)

if len(sys.argv) != 2:
    print("Error: specify an IP to connect to!")
    exit(0)

ip = sys.argv[1]

NetworkTables.initialize(server=ip)
sd = NetworkTables.getTable("SmartDashboard")

for i in range(1000000):
    if i % 100 == 0:
        print(i)
    sd.putNumber("dsTime", i)
    NetworkTables.flush()
    time.sleep(0.001)

Server:

#!/usr/bin/env python3

import time
from networktables import NetworkTables

# To see messages from networktables, you must setup logging
import logging

logging.basicConfig(level=logging.DEBUG)

NetworkTables.initialize()
sd = NetworkTables.getTable("SmartDashboard")

# hack: grab internals for debugging
with NetworkTables._api.storage.m_mutex:
    entry = NetworkTables._api.storage._getOrNew("/SmartDashboard/dsTime")

i = 0
while True:
    print("dsTime:", entry.value, entry.seq_num)
    sd.putNumber("robotTime", i)
    time.sleep(1)
    i += 1

I've been told that in 2019 LabVIEW had an issue with this, so it sounds like it's either (a) an interop issue or (b) a problem with LabVIEW. I'd like to know if the user can reproduce this with the ntcore library.

virtuald commented 4 years ago

This is apparently a known issue regarding ntcore/LabVIEW interoperability, so going to close as not a bug.

https://docs.wpilib.org/en/latest/docs/software/wpilib-overview/known-issues.html#networktables-interoperability