Fastest way to append a string to a text file w/o impact(effect) on web site load time
Question: Suppose my web site needs to run this python code  
for everytime it loads..

    
    
    f = open('/aaa', 'a')
    f.write('test' + '\n')
    

all it does is.. "append" .. "test" to "/a" file.

but perhaps there is a way to run this command without having impact on the
web site load time.

perhaps it can be forked ?

but the only way to do that would be to.. use

    
    
    import os
    os.popen()
    

which sounds like can make things even more heavy.

based on my understanding.. things such as "APACHE"..  
can append lines to files such as error_log at amazing speeds.

and i think i read somewhere that apache actually appends lines to error_log
and  
access_log without even opening those files.

is there a way to do things that way from a python script ?


Answer: I think you can put these file IO operations into another thread in your main
process. Just execute this Python script in another thread paralleled. If your
main process is written by Python, try to use `threading` module. Hope it
helps.

