intrig-unicamp / mininet-wifi

Emulator for Software-Defined Wireless Networks
https://mn-wifi.readthedocs.io/
Other
432 stars 239 forks source link

Using threading with net.plotGraph #348

Closed phantomxe closed 3 years ago

phantomxe commented 3 years ago

I need to change a station position from a running code at another thread. If i use setPosition method on station, it fails like;

....
    self._idle_callback = self._tkcanvas.after_idle(idle_draw)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 614, in after_idle
    return self.after('idle', func, *args)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 606, in after
    name = self._register(callit)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1228, in _register
    self.tk.createcommand(name, f)
RuntimeError: main thread is not in main loop

I tried also just set position tuple and i got no error but this time the graph is not changed. There is no effect. I called update graph method from after setting position then i got same error message.

ramonfontes commented 3 years ago

Have you ever tried sockets?

https://mininet-wifi.github.io/advanced/#socket

phantomxe commented 3 years ago

@ramonfontes i will try now.

phantomxe commented 3 years ago

@ramonfontes why client need to kill the socket after sending each command? I try to send lots of commands and it crashes the mininet.

ramonfontes commented 3 years ago

I don't remember exactly but I had experienced some issues. However, you are free to do the work without stopping it if you can.