Variables in a loop, Newby question

Chris Angelico rosuav at gmail.com
Wed Dec 25 20:35:48 EST 2013


On Thu, Dec 26, 2013 at 12:01 PM, Cameron Simpson <cs at zip.com.au> wrote:
> On 25Dec2013 15:27, Denis McMahon <denismfmcmahon at gmail.com> wrote:
>> On Wed, 25 Dec 2013 16:42:47 +1100, Cameron Simpson wrote:
>> > On 25Dec2013 02:54, Denis McMahon <denismfmcmahon at gmail.com> wrote:
>> >> On Tue, 24 Dec 2013 10:27:13 -0800, vanommen.robert wrote:
>> >> > In this script i want to read the temperatures and make them
>> >> > available to other scripts. [...]
>> >> If you want this process to provide data to other processes, you might
>> >> want to look at using a socket so they can request it as needed.
>> >
>> > Or just write it to a file for another process to open and read...
>>
>> That can cause io sync errors, eg if another process has the file opened
>> for read when you try to write, or you are writing when they try to read.
>
> Well, obviously synchronisation of some kind is needed. The easiest
> is write-new-file-with-temp-name followed by rename(). Atomic. Lock
> files are also not too hard, etc.

Does anyone else have the vague feeling that the OP's problem might be
better served by simply importing the script (thus making those values
available to another Python script) than by any of these rather more
complicated theories?

Of course, this requires a little more clarification from the OP, but
I'd rather posit the simple idea and see it knocked down before going
on to the complex :)

ChrisA



More information about the Python-list mailing list