![]() |
| |||||||
Automation Anywhere Post messages and questions related to Automation Software here. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| |||
|
10 tasks are running in parallel. Some instructions (at random time intervals using delays) may try to read a File “FileA” in each task. At one time only one task should read the file, other files trying to read the same file should wait until the file is free to read (no task is reading the file). Is there any way to achieve this though Automation Anywhere? |
| |||
|
Hello, You cannot run two Automation Anywhere tasks simultaneously. However, you can run two exes of task simultaneously. Can you please tell us, all the tasks are accessing the text file through 'Read from Text file' variable? When more than one exe tries to access same text file, the operating system will grant full access to the first exe and the subsequent exes will get the read only access. However, the exe will continue to run. Read only access would not stop running the exe. Hope that helps. |
| |||
|
Yes I wanted to refer to exe files only. So,does that mean we cannot achive this though Automation Anywhere, coz my requirement is to allow only one exe to read the common text file one at a time ? Is there any other workaround in Automation Anywhere? |
| |||
|
Hello, Can you please tell us, is your task just reading the text file or it is also writing in it? In later case i.e. task is writing in a text file, an error will be produced when two exes tries to access the same file at the same time. You can handle this error using Error Handling command (Available only in Enterprise version). You can continue the task after the block where the error occurs, or stop the task. You can find this command under 'Advanced' command category. When an error occurs, Automation Anywhere can take the following actions: . Take a snapshot of the screen . Run another task . Log data in a file . Send an email All four options can be performed together or in combination. For example, you can run a task and log data into a file. Hope that helps. Last edited by forumsupport; 02-04-2009 at 08:07 AM. |
| |||
|
Hi, Actually multiple tasks will read this file only one task will write the status in the file. While TaskA is updating the file no other task should read the shared file. But I am not able to stop any task from reading this file, I tried with random delays in different tasks couldn't stop other tasks from reading the file but it didn't work. So,How do I stop other tasks from reading this file? |
| |||
|
Hello, What you can try is, . In TaskA insert 'Create File' command to create a temporary file say ToBeDeleted.txt on shared network, before the command that is writing the status in the shared file. . At the end of task, insert 'Delete Files' command to delete ToBeDeleted.txt file. Text format of commands in TaskA would appear something like this, Create Text File "X:\ToBeDeleted.txt" Log to File: Logging the status in "X:\SharedFile.txt" Delete Files "X:\ToBeDeleted.txt" . In TaskB, insert Loop command with condition in order to wait until X:\ToBeDeleted.txt exists. As soon as TaskA deletes the file, the Loop condition would become false and task would come out of loop to execute subsequent commands in TaskB. Loop While File Exists("X:\ToBeDeleted.txt") Delay: (300 ms) End Loop Comment: Commands in TaskB should follow Hope that helps. |
| |||
|
Hi, Loop While File Exists("X:\ToBeDeleted.txt") Delay: (300 ms) End Loop I see the problem with this code piece is that in case of multiple exe running and say 5 exe files waiting for the condition to be true and when its true at least 3 exe will get in side the loop and therefore we fail to avoid the race condition again. Please let me know if you otherwise. |
| |||
|
Hello, The solution was for the condition, while TaskA is updating the file no other task should read the shared file. If you wish the same thing for all the tasks i.e. at a time only one task can read or write a file then include following commands in the beginning of every task, Loop While File Exists("X:\ToBeDeleted.txt") Random Delay ( From 1000 to 3000 ms) End Loop Create Text File "X:\ToBeDeleted.txt" Comment: Commands in Task should follow Delete Files "X:\ToBeDeleted.txt" Insert Random delay inside the loop so that no two tasks can get inside at the same time. Hope that helps. |
![]() |
| Thread Tools | |
| Display Modes | |
| |