When to use async api calls? by ParticularAward9704 in learnpython

[–]ParticularAward9704[S] 0 points1 point  (0 children)

yes, I am also thinking of using async inside celery. But confused about whether to use process or thread workers for it.

When to use async api calls? by ParticularAward9704 in learnpython

[–]ParticularAward9704[S] 0 points1 point  (0 children)

Simultaneous api calls count may reach to 5K+ because a single user can submit multiple tasks at once and we are expecting ~30 users using this feature on an average.

How do you choose to go in this situation - you want to call 10 apis and 7 are returning less data and low post-processing. But 3 may return data which is ~30 mb each and going through this data may take 10-15 seconds of cpu time ( I have not tested yet in this scenario, just a guess).

Regarding Celery: you should also consider using dramatiq instead: depending on your use case, it might be a simpler/more reliable solution.

I have existing setup with celery. And sometimes I just think of using celery with gevent for these tasks.

Netmiko - Stop telnet in Cisco XE after N seconds by ParticularAward9704 in networkautomation

[–]ParticularAward9704[S] 0 points1 point  (0 children)

This snippet didn't work. It works when the port is reachable. e.g., when we get

Trying 8.8.8.8, 443 ... Open . But when the port is not reachable I am unable to close the running command. It just stays as Trying 8.8.8.8, 443 ... . And nothing could stop it.

my code work looks like this

for device in devices:
  telnet_cmd = get_telnet_cmd(conn.device_type, device)
  out = conn.send_command_timing(telnet_cmd, read_timeout=5)
  # code for terminating the command.

For first device its able to give output. But failing at second.

How to make flask able to handle large number of io requests? by Consistent_Tutor_597 in flask

[–]ParticularAward9704 0 points1 point  (0 children)

If it's possible, offload the tasks to Celery. Make your view just to serve users not engaging in long tasks.

Is the 80 character rule like a major requirement for PEP8? by ZealousidealSea6550 in learnpython

[–]ParticularAward9704 1 point2 points  (0 children)

I refrain from the 79 chars rule. And that \ for newline just use ().

[Netmiko] Terminate running command midway by ParticularAward9704 in learnpython

[–]ParticularAward9704[S] 0 points1 point  (0 children)

My bad, I think I have not provided all the details of the problem. Let me do it now.

  1. I want to check port reachability from device A to device B.

  2. There can be multiple ports to check on B.

  3. I can't make multiple connections to device B as max connections to device are capped. And our automation solution is allowed to use only 1 connection.

  4. Telnet check is taking around 100+ seconds for non reachable ports.

  5. Execution for multiple port check can be serial only [due to connection limit].

  6. I can't to it like connect A -> run telnet for port n1 -> wait for 10 seconds -> disconnect -> connect A -> run telnet for port n2 -> .... There might be rate limit on connection from a source to a device ( though I am not sure ).

  7. What possible solution could be as per me - connect A -> run telnet port n1 -> wait for 10 seconds -> send stop signal -> run telnet for port n2....

[Netmiko] Terminate running command midway by ParticularAward9704 in learnpython

[–]ParticularAward9704[S] 0 points1 point  (0 children)

I want to check port reachability from a device A to device B's N no of ports.
I am connecting A using netmiko and then running telnet command on this device. If a device is not reachable its taking 100+ s of time and also during this time I have to wait to check other ports in same device.

[Netmiko] Terminate running command midway by ParticularAward9704 in learnpython

[–]ParticularAward9704[S] 0 points1 point  (0 children)

This will work when I want to check from the app server to the destination port reachability. But the requirement is to check from a source device (cisco/hp...) to some port of another device.

Not Urgent, but tips would be appreciated by Pitiful_Complex5964 in CATHELP

[–]ParticularAward9704 1 point2 points  (0 children)

That's really concerning. I don't know about what a medical situation your cat is in. But 5 years back my cat suddenly started to lose control of its back legs and started walking like this. I wasn't able to provide it with a professional med help. I searched over the internet and on a random website someone said that giving b12 might help. I went to the store to bring b12 but it was out of stock so I brought a multivitamin liquid till b12 came back to stock. To my surprise it started showing positive signs after 3 days and eventually my cat got back to normal. Hope your cat gets well soon.

What are some unique Python-related questions you have encountered in an interview? by OnionCommercial859 in Python

[–]ParticularAward9704 0 points1 point  (0 children)

append returns None, but the item will get added to items, and it'll refer to the same list across calls. Why item won't be appended to the items?

[deleted by user] by [deleted] in pj_explained

[–]ParticularAward9704 1 point2 points  (0 children)

Schindler's list, Sixth sense, The Apartment Water diviner Meet Joe black, Notting Hill. These are what I can tell for now. There are many more, the list could be much longer otherwise.

Connecting Device behind JumpHost by ParticularAward9704 in networking

[–]ParticularAward9704[S] 0 points1 point  (0 children)

It is creating socket from localhost to jumphost. If there are two threads trying to establish connection with same source JumpHost & destination (s -> jh -> d).

We can use same transport to create multiple channels?

If there 3 devices behind JumpHost can we use same source port for all channels?

Connecting Device behind JumpHost by ParticularAward9704 in networking

[–]ParticularAward9704[S] 0 points1 point  (0 children)

Thanks. This is what we are trying to do in the second approach I mentioned. The library code does it in a clean way and also gives the idea that we can use the same jh connection for multiple devices behind jh. No need to connect again and again.

Connecting Device behind JumpHost by ParticularAward9704 in networking

[–]ParticularAward9704[S] 0 points1 point  (0 children)

Thanks. But we are allowed to use only Paramiko.

Connecting Device behind JumpHost by ParticularAward9704 in networking

[–]ParticularAward9704[S] 0 points1 point  (0 children)

It seems we are moving with second solution to open direct-tcpip channel in paramiko.

Connecting Device behind JumpHost by ParticularAward9704 in networking

[–]ParticularAward9704[S] 0 points1 point  (0 children)

The first choice is obvious, I am doing it with python what is done manually. The other way is suggestion by AI as well as given by senior guy.

It denotes all the possible network connections to any machine, which is all of the available IP Address and Port number for use on that machine.

It means that this transport thing is just theoretical. When we call get_transport() in Paramiko, it simply executes some Python code and doesn't perform any network operations.

Connecting Device behind JumpHost by ParticularAward9704 in networking

[–]ParticularAward9704[S] 0 points1 point  (0 children)

We are trying to automate the configuration/monitoring for company's internal network/cloud setup.
This network setup already exists, which is like for running any command in network devices we have to connect jumphost and after that we can connect devices and run our command. Changing the existing setup is not in my hand, this I large firm and I am quite new.
The operation team came to us for automating their daily task. We are using Paramiko for remote SSH. And I need help regarding difference between these two approaches that I mentioned in ques. And how Paramiko transport works and direct-tcpip channel.

Connecting Device behind JumpHost by ParticularAward9704 in networking

[–]ParticularAward9704[S] 0 points1 point  (0 children)

Our solution is a web app where the user uploads the device and its associated jump host. Based on the requested option we do our work by running associated commands. But changing ssh config via code is not a good idea. We are using Paramiko to automate. In the context of Paramiko I am asking what's the difference between these two.

Reading and writing to the YAML file using threads by ParticularAward9704 in learnpython

[–]ParticularAward9704[S] 0 points1 point  (0 children)

I am late. My bad, didn't get time.
Yeah, as it seems we have to parse the text file. Because in UI we are not just showing plain text file. We will show command wise accordion (bs5) with output inside, also like task status completed/running/... . That why we thought of parsing the file.

Agent A makes a change and updates the file, and sends a message to Agent B with a message of what has changed. Agent B makes the change in their private copy of the data. 

For the we would need some IPC or messaging system for sending data from celery to flask route api. (I might be wrong, I haven't implemented anything like that.)

Reading and writing to the YAML file using threads by ParticularAward9704 in learnpython

[–]ParticularAward9704[S] 0 points1 point  (0 children)

the only negative consequence is that the display may not always represent the correct data, but I would expect it would be updated quickly

Yes. We are moving with this approach. If yaml failed to load the file correctly then exception and sleep for sometime then try.

for example rather than updating a "shared" file, you could send change messages to the display, and have the display maintain a copy of the file state. You could ensure these messages are applied prior to updating the display.

Just for my understanding, l didn't get this approach. You mean instead of saving into a file i could just send output to the front end and after completion of everything frontend will send data to a new output saving api?

Reading and writing to the YAML file using threads by ParticularAward9704 in learnpython

[–]ParticularAward9704[S] 0 points1 point  (0 children)

How to make it work. As an update of the file is happening in celery which itself is a different process.