Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8960567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:41:16+00:00 2026-06-15T15:41:16+00:00

I can do it with .txt files, that when something is happening it writes

  • 0

I can do it with .txt files, that when something is happening it writes “ok”, and an other program reads it and do something if the .txt file has “ok” inside it. But, I would like to know if I can do with another way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:41:17+00:00Added an answer on June 15, 2026 at 3:41 pm

    You could use a signal, e.g. USR1, but I don’t think you can raise signals in Python.
    Instead of communicating via a file as you do now you can use a named pipe. A named pipe will provide some extra functionality, see last paragraph.

    You open the pipe as an ordinary file and then write and read as you do now. You create the pipe by mkfifo filename, can also be created in your python program. Two example programs for demo:

    Sender:

    fdw= os.open("./mypipe", os.O_WRONLY)
    while (1):
     try:
        os.write(fdw, "OK\n")
     except OSError, e:
        if e.errno==errno.EPIPE:
            #Receiver closed the pipe                                                   
            print "Reader closed pipe\n"
            sys.exit(0)
        else:
            #some other os problem                                                         
            print os.strerror(e.errno)
      time.sleep(3)
    

    Receiver:

    fdr= os.open("./mypipe", os.O_RDONLY | os.O_NONBLOCK)
    while (1):
      try:
        s= os.read(fdr, 10)
        print s
      except OSError, e:
        if e.errno==errno.EBUSY:
            print "nothing to read yet\n"
        else:
            print os.strerror(e.errno)
      time.sleep(1)
    

    The sender opens a blocking pipe, so you will get an exception if the receiver closes the pipe, usually while terminating. The reader opens a non-blocking pipe so it will not hang while waiting for anything written by the sender. Combinations of blocking/non-blocking yield different responses when sender or receiver close one pipe end. You may want to open the write end non-blocking if there are any chance of pipe overflow (kbytes written, nothing read).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to restrict my web app so that .txt files can not be
I have a file that can be any thing like ZIP, RAR, txt, CSV,
I have a pile of batch files that do something like this with program
How can I copy all files that have a [dot]something to a flash dirve
I have a txt file that has many rows of lines I want to
I wrote a script that reads each file in a directory, does something and
Suppose I have some text files (f1.txt, f2.txt, ...) that looks something like @article
Exact error: $ ./script.pl file.txt Can't open file.txt: No such file or directory at
How can I create a .txt file using flex 3? And I want to
The code chokes at fopen(): <?php ini_set('display_errors',1); error_reporting(E_ALL); $fp = fopen(/path/to/file/some_file.txt,a) or die(can't open

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.