[ExM Users] File race condition?

Tim Armstrong tim.g.armstrong at gmail.com
Thu Apr 16 12:31:02 CDT 2015


You're right, app functions automatically created the output folders -
write() didn't - it was a bit inconsistent.

- Tim

On 16 April 2015 at 11:32, Ozik, Jonathan <jozik at anl.gov> wrote:

>  Thanks Tim, this will do the trick.
> I thought I was seeing that in some situations the necessary folders were
> being created but not in others. I could be wrong though.
>
>  Jonathan
>
>  On Apr 15, 2015, at 9:05 PM, Tim Armstrong <tim.g.armstrong at gmail.com>
> wrote:
>
>  I think the problem is just that the directories the file is in isn't
> automatically created by write.  It probably would make sense for it to, so
> I'm checking in a fix to that.
>
>  As a workaround you could just do a mkdir before you use the directory:
>
> import io;
> import sys;
> import files;
>
> main
> {
>     string upf_file_name = argv("f"); // e.g., -f="upf.txt"
>     string upf_lines[]  = file_lines(input(upf_file_name));
>     foreach s,i in upf_lines
>     {
>       string instance_dir = strcat(strcat("instance_",fromint(i)),"/");
>
>       my_mkdir(instance_dir) =>
>       {
>         file out <strcat(instance_dir,"out.txt")>;
>         file err <strcat(instance_dir,"err.txt")>;
>         file tmp <strcat(instance_dir,"upf.txt")> = write(s);
>       }
>     }
> }
>
> app (void o) my_mkdir(string dirname) {
>   "mkdir" "-p" dirname;
> }
>
>
> On 15 April 2015 at 20:03, Ozik, Jonathan <jozik at anl.gov> wrote:
>
>> Hello all,
>>
>> I’m wondering if I’m seeing an unintended file I/O race condition or if
>> I’m simply doing something wrong but I’m getting errors when trying to
>> execute this script using trunk:
>>
>> swift-t -n 4 very_simple.swift -f=upf_small_3.txt
>> (where upf_small_3.txt is a file with 3 lines)
>>
>> ##### very_simple.swift #####
>> import io;
>> import sys;
>> import files;
>>
>> main
>> {
>>     string upf_file_name = argv("f"); // e.g., -f="upf.txt"
>>     string upf_lines[]  = file_lines(input(upf_file_name));
>>     foreach s,i in upf_lines
>>     {
>>       string instance_dir = strcat(strcat("instance_",fromint(i)),"/");
>>
>>       file out <strcat(instance_dir,"out.txt")>;
>>       file err <strcat(instance_dir,"err.txt")>;
>>       file tmp <strcat(instance_dir,"upf.txt")> = write(s);
>>     }
>> }
>> ##### very_simple.swift #####
>>
>> The errors are:
>> couldn't open "instance_1/upf.txt": no such file or directory
>>     while executing
>> "::open [ local_file_path $local_file ] w+ "
>>     (procedure "turbine::file_write_local" line 3)
>>     invoked from within
>> "turbine::file_write_local v:tmp ${v:s}"
>>     (procedure "__entry-call_foreign-write" line 5)
>>     invoked from within
>> "__entry-call_foreign-write {2  randomSeed      1,zombieStep
>> 0.1,humanStep   0.5,human_count 200,zombie_count        2}
>> instance_1/upf.txt {file 7 is_mapped 1}"
>> Turbine worker task error in: __entry-call_foreign-write {2
>>  randomSeed      1,zombieStep    0.1,humanStep   0.5,human_count
>> 200,zombie_count        2} instance_1/upf.txt {file 7 is_mapped 1}
>>     invoked from within
>> "c::worker_loop $WORK_TYPE($mode) $keyword_args"
>>     (procedure "standard_worker" line 27)
>>     invoked from within
>> "standard_worker $rules $startup_cmd "
>>     (procedure "enter_mode_unchecked" line 5)
>>     invoked from within
>> "enter_mode_unchecked $rules $startup_cmd"
>>     (procedure "enter_mode" line 5)
>>     invoked from within
>> "enter_mode $rules $startup_cmd “
>>
>> Jonathan
>> _______________________________________________
>> ExM-user mailing list
>> ExM-user at lists.mcs.anl.gov
>> https://lists.mcs.anl.gov/mailman/listinfo/exm-user
>>
>
>  _______________________________________________
> ExM-user mailing list
> ExM-user at lists.mcs.anl.gov
> https://lists.mcs.anl.gov/mailman/listinfo/exm-user
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/exm-user/attachments/20150416/8c5841e0/attachment.html>


More information about the ExM-user mailing list