Re: [pysnmp-users] CLI interaction?
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2015-11-14 18:14:56
|
The first thing I do not quite understand is why your SNMP call blocks (?) your cly app if your (blocking) pysnmp code runs in a dedicated thread. Can you please elaborate on that point? Alternatively, as Craig says, you may try to switch your stdin file descriptor into non-blocking mode and serve both FD's (SNMP and stdin) by a single select() within a main loop. To start with the second approach, I'd investigate the way how to extent ply input driver to run non-blocking and being managed by a select(). I've looked at the ply code: https://github.com/alecthomas/cly/blob/master/cly/interactive.py so ReadlineDriver class is the place that should probably be hacked/extended to replace blocking raw_inpit() with a non-blocking and select()-managed version like discussed here: http://stackoverflow.com/questions/9027311/how-to-make-non-blocking-raw-input-when-using-eventlet-monkey-patch-and-why-it Once this is working, I could elaborate on two-FDs-been-managed-by-single-select thing. I will probably try to come up with an example script to make it generally useful. -ilya On 11/12/2015 11:15 AM, Craig Small wrote: > Avtually re-reading your email, its not two sockets its an interactive > terminal and a socket. What you can do is put your stdin socket (well > FD) into the socket map. That way the select() is looking at both your > network SNMP socket/fd and your keyboard stdin > > - Craig > > > On Thu, Nov 12, 2015 at 9:09 PM Craig Small <cs...@en... > <mailto:cs...@en...>> wrote: > > > Get's a bit tricky with sockets floating around. What I had to do > was create a new SNMP engine and dispatcher that used my own > socket_map. The socket_map is important because this is what the > select() system calls to listen for the sockets. You can have only > one select() > > You then need to run the dispatcher's jobsArePending and > handleTimerTick to keep the the snmp dispatcher happy. > > I then have the the socket running select(), because you have used > YOUR socket_map then pysnmp has added its socket to the map. > I asked almost the very same thing and Ilya responded here: > > http://sourceforge.net/p/pysnmp/mailman/message/31494830/ > > > > On Thu, Nov 12, 2015 at 11:57 AM Michael R Anderson > <mic...@gm... <mailto:mic...@gm...>> > wrote: > > I am using cly to drive my CLI. It works great. I recently added > pysmp. Now when it gets to runDispatcher() (in it's own thread), it > looks like my CLI input line gets hijacked so that no more command > line input can be done. > > I read runDispacther uses an I/O mainloop somehow. Can this be > causing my CLI is no responsive problem? > > Any suggestions? > > ------------------------------------------------------------------------------ > _______________________________________________ > pysnmp-users mailing list > pys...@li... > <mailto:pys...@li...> > https://lists.sourceforge.net/lists/listinfo/pysnmp-users > > -- > Craig Small (@smallsees) http://enc.com.au/ csmall at : > enc.com.au <http://enc.com.au> > Debian GNU/Linux http://www.debian.org/ csmall at : > debian.org <http://debian.org> > GPG fingerprint: 5D2F B320 B825 D939 04D2 0519 3938 F96B > DF50 FEA5 > > -- > Craig Small (@smallsees) http://enc.com.au/ csmall at : > enc.com.au <http://enc.com.au> > Debian GNU/Linux http://www.debian.org/ csmall at : > debian.org <http://debian.org> > GPG fingerprint: 5D2F B320 B825 D939 04D2 0519 3938 F96B DF50 FEA5 > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > pysnmp-users mailing list > pys...@li... > https://lists.sourceforge.net/lists/listinfo/pysnmp-users > |