Python Forum
creating python server and client in a pc
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
creating python server and client in a pc
#1
hi, sorry for my bad English,
this is my first post, so sorry if I have mistakes,

currently, I using dl-translate packages to bulk translate all of my txt in a folder,
for this case, the content is a word from "Top 100 most common Spanish words"
so you can guess there are 100 of txt files,

this is the flow chart of the script:
1. load the dl-translate to RAM, because it loaded from Harddisk/not SSD, the average loading time take about 15 seconds,
2. check if the folder contain(s) txt files, if exist: go to step 3, if not exist: go to step 8,
3. read the string from a txt file
4. translate string from step 3,
5. move txt file from step 3 to subfolder "source_done",
6. create txt result file to subfolder "translate_result",
7. go to step 2,
8. end program/script,

this script works flawlessly, except if the source is wrong, the wrong is usually a typo,
each time I found a typo, I need to fix it, then I need to run that "8 steps" script at above again,

somehow to check if the result is right, I must fix 1 file at a time:
if the wrong only 1 or 2 files, waiting only 15-30 seconds is acceptable,
for 4 txt alone it requires 1 minute, but if dozen(s) you can count by yourself,

now my question is:
is possible to create an "always running python script" as a server, in this case, the script does step 1?
then another python script "hook" it as a client, in this case, to do steps 2-8?

an answer as google keyword is good,
an answer as a link or script is great,

thank you for reading, have a nice day.
Reply
#2
rethink your workflow. instead of ending the program display the word in the file and ask user to correct it.
Gribouillis likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Nov-29-2021, 08:31 AM)buran Wrote: rethink your workflow. instead of ending the program display the word in the file and ask user to correct it.

thank you for the reply buran,
sorry if my "case study" seems stupid,
but I like to know if this "client and server" things can be done by the python or not

and sorry again for my bad English, I don t understand the sentence:
"instead of ending the program display the word in the file and ask user to correct it."
what do must I do?
Reply
#4
Why not use a web server such as cherrypy ? https://docs.cherrypy.dev/en/latest/

Innumerable servers exist in Python. The standard library contains a socket server, a http server, a xmlrpc server, etc. Many web frameworks exist.

You can also use remote procedure call modules such as Rpyc to achieve your goal https://rpyc.readthedocs.io/en/latest/
kucingkembar likes this post
Reply
#5
thank you Gribouillis, i will study it

edit:
I study both of your links
-cherrypy,
this for web server, too many things to do is using this

-Rpyc
this what I looking for, even I still don't understand why
root.echo = exposed_echo
in this code:
#server.py
import rpyc
from rpyc.utils.server import ThreadedServer

class MyService(rpyc.Service):
    def exposed_echo(self, value):
        return value * 2

if __name__ == "__main__":
    server = ThreadedServer(MyService, port = 18812)
    server.start()
#client.py
import rpyc
c = rpyc.connect("localhost", 18812)
print(c.root.echo(3))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Networking Issues - Python GUI client and server connection always freezes Veritas_Vos_Liberabit24 0 679 Mar-21-2023, 03:18 AM
Last Post: Veritas_Vos_Liberabit24
  Getting "SSL client not supported by this Python installation" error prabirsarkar 0 915 Mar-13-2023, 05:01 PM
Last Post: prabirsarkar
  Real-Time output of server script on a client script. throwaway34 2 2,010 Oct-03-2021, 09:37 AM
Last Post: ibreeden
  How to take the tar backup files form remote server to local server sivareddy 0 1,871 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  Python win32com.client: What are the syntax to open exe file & activate its window? JaneTan 0 4,130 Oct-14-2020, 09:09 AM
Last Post: JaneTan
  Creating a list of RSSI value and send it to the server. Azuan 0 2,615 Jun-08-2020, 11:22 PM
Last Post: Azuan
  Python sockets : Client sending to the server nico31780 0 2,276 May-17-2020, 07:56 PM
Last Post: nico31780
  client-server pictures mcgrim 4 2,917 Oct-25-2019, 09:53 PM
Last Post: micseydel
  Internal Server Error 500 on creating .py file patrickluethi 0 1,717 Aug-02-2019, 01:57 PM
Last Post: patrickluethi
  Handling Thick client applications using Python PraveenSubramaniyan 1 3,177 Jul-22-2019, 01:08 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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