Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

question on using tmuxp to run different part of my code. #36

Open
ycui opened this Issue · 5 comments

2 participants

@ycui

Hi,

I have a question regarding the usage of tmuxp :

For example say I have an iteration from 1 to 100.

in one terminal i need to run:

for i in range(100):
print i

I would like to know if it's possible to separate this work into four parts and run the following in each part:

for i in range(25):
print i

I don't want to write yml or json config file for this run, but want to integrate them into the codes. can you please offer some hints?

Thanks

@tony
Owner

@ycui:

It would help me to know more about the script's behavior / big picture. What are you trying to do? Is this a python script?

Any snippets / etc. you can share? How would you envision the workflow to be?

I would like to help write an example so it can used it to demonstrate the API.

@ycui

Hi Tony,

Thanks for the quick reply. My workflow is a python script to sequentially login to a number of network devices and perform some duties there. It's written in a for loop which iterate over the device objects and the device object itself calls its method to perform the work.

Due to the large number of devices, I would like this work to be separated into 2 or 4 pieces, and I hope it could be shown on different blocks of the screen. I thought tmuxp should support such functionality.

As to the actual code snippet, I haven't got it hosted on github, but you can consider it as breaking a for loop into different sections and running them in different parts of the screen.

Thank you.

@tony
Owner

This has been very thought provoking. This is exactly the place tmuxp can shine very well.

Exactly. 1 Windows, an each section is a pane.

http://tmuxp.readthedocs.org/en/latest/about_tmux.html

One thing to be aware of is, each pane needs a way to communicate.

Have you investigated ways this could be done asynchronously / with a queue?

I am going to think this over more. Tmuxp's API would be very useful.

Imagine you have terminals open and you want the script to communicate via the For loop via a Queue (via it zeromq, twisted, etc.). If you could send me the boilerplate to how you're doing that, I could piece together an example faster.

@ycui

Hi Tony,

Sorry for the late reply and happy new year.

The following is my sample client script to run few executions on different devices concurrently, by using the python built-in Threading and Queue module.

https://github.com/ycui/INWK_Device_Manager/blob/master/t_run.py

Thanks

@tony tony was assigned
@tony
Owner

@ycui - I have a lot on my plate right now. I am assigning this to me.

This is common enough of a use case for tmux (especially with tmuxp involved) it should be used as an example. I will ping here when I have a demonstration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.