Python Forum
Alternative for input() suitable for servers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alternative for input() suitable for servers
#1
If i use the input() function on my server, the server freezes because it waits for an input.
How can read what i write in the console? I need this to use commands for example but also to send messages to clients
Reply
#2
myvar = input('type something: ')
print(myvar)
Reply
#3
winnetrie Wrote:If i use the input() function on my server, the server freezes because it waits for an input.
"Server" is a blanket term, it can mean anything. If you don't explain the issue with more details, it is very difficult to help.
Reply
#4
I'm not sure what is not understandable with "server". For me a server is a server. I don't know how to explain that better, but i'll give it a try:
So the server i have, hosted on my own pc for now, has to become a login server for clients( made in gamemaker).

People can registrate on my website to create an account. The client can use that account to login on the server, that will verify that account. Account data is stored in the database.
I also want to add some extra features to the server, like a chatbox, friendlist. More important, i also want to be able to use commands (self made commands) in the console. But to read some input from the console i usually use input(). Alas input() is also blocking, so the server freezes all activity untill it gets that input(). Ofcourse i do not want it to freeze. I create a new thread for each client, wich works fine (i think), i also create a thread for the server itself (for sending commands or if sending customized messages)but then again input() just freezes the whole program. So here i am to ask advice or an alternative solution to be able to read input without freezing the whole program.
I am used to program in gamemaker studio 2 (GMS2), GMS2 has a builtin variable "keyboard_string". This variable returns keyboard input and you can reset it or empty it just by doing keyboard_string = "" Simple as that. I couldn't find anything like that in python. I googled alot but i can only find amazing complex solutions wich do not work either (or i'm doing something wrong)


I hope it is understandable now Tongue
Reply
#5
I would have expected threads to help. The last thing I would try with them, which you didn't seem to describe, would be to call input() in a separate thread. It's hard to comment on your code without... seeing any code.

Other than that, I think using input() in a server context like that is weird. What would probably be better is some kind of admin dashboard through your webapp.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Twilio alternative jmair 3 3,916 Feb-08-2024, 01:55 PM
Last Post: Sharmi
  Pillow alternative? kucingkembar 4 882 Jul-27-2023, 10:50 AM
Last Post: Larz60+
  how to manage crypto trading flooding data from exchange servers Mikeardy 0 1,243 Dec-26-2021, 08:31 PM
Last Post: Mikeardy
  Help for the shortest way to install a suitable version of Python, Numpy, and OpenCV. Ezzat 2 2,303 Dec-23-2021, 12:34 PM
Last Post: snippsat
  Improves performance on socket multi-threaded servers for object detection pennant 1 1,907 Aug-31-2021, 08:43 AM
Last Post: Larz60+
  suitable libraries for project dogbural 0 1,442 Dec-29-2020, 12:38 PM
Last Post: dogbural
  Alternative for Cairosvg? Maryan 0 2,466 Oct-26-2020, 01:27 PM
Last Post: Maryan
  Create a directory structure across many servers metro17 1 1,758 Nov-05-2019, 03:35 PM
Last Post: Larz60+
  OOP and module approaches in a simple app monitoring list of servers hjzxxzjcz 1 48,682 Nov-01-2019, 04:30 PM
Last Post: nilamo
  another alternative to np.interp evelynow 1 2,930 Aug-22-2019, 03:32 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020