Jump to content
UBot Underground

Multiple Threads Writing To One File?


Recommended Posts

Hi guys,

Can Ubot handle it if I have multiple threads appending to one file?

I've seen no problem so far but I'm just afraid that if 2 threads writing to a file at the same time it will cause some text not being written to the file.

 

Please clear this up for me. Thanks

Link to post
Share on other sites

Hi guys,

Can Ubot handle it if I have multiple threads appending to one file?

I've seen no problem so far but I'm just afraid that if 2 threads writing to a file at the same time it will cause some text not being written to the file.

 

Please clear this up for me. Thanks

 

Use Free TinyMCE  Plugin to lock your file and than do the write operations so that no 2 threads can write it at a time. 

Link to post
Share on other sites

Use Free TinyMCE  Plugin to lock your file and than do the write operations so that no 2 threads can write it at a time. 

Thank you very much.

So with the plugin, if 2 threads try to write at the same time, will one thread wait for the other to finish and then write?

Link to post
Share on other sites

Thank you very much.

So with the plugin, if 2 threads try to write at the same time, will one thread wait for the other to finish and then write?

 

Yeah this is the expected behavior of threads, you can test it with dummy data before doing anything with ur original data

Link to post
Share on other sites

Hello.

 

I would recommend the free File Management Plugin:

plugin command("File Management.dll", "locked save to file", "", "")

 

It has a thread safe save to file command.

 

The problem with the lock command is, that it needs to execute the ubot command in an APi Container. And there are some known issues with Threads and API Containers. 

 

So I would go for the File Management Dll:

http://network.ubotstudio.com/forum/index.php/topic/13237-free-file-management-plugin-multiple-commands-and-functions/

 

Cheers

Dan

  • Like 2
Link to post
Share on other sites
  • 2 weeks later...

Good call Dan. I gotta tell you that the file management plugin is like the best free plugin around.Saved my bacon on several occasions.

 

Frank

Link to post
Share on other sites
  • 2 years later...

Hello guys,

 

What is the 2018 way to go, when appending to 1 file at multiple threads? I have fear my bot is crashing because of that.

 

i dont want to collect all data in a variable because when bot crashes all is gone.

 

The recommendation from Dan can only save and not append.

plugin command("File Management.dll""locked save to file"""""),

i dont want to read the file first and then save it, over multiple threads, this is not practicable for me.

 

for the tiny mce usage i did not have found any demo code yet.

 

The other old plugin, with the lock{ function, didnt appear in the plugins.

 

Many thanks, any help much appreciated!  :)

Edited by ibins
Link to post
Share on other sites

Hello guys,

 

What is the 2018 way to go, when appending to 1 file at multiple threads? I have fear my bot is crashing because of that.

 

i dont want to collect all data in a variable because when bot crashes all is gone.

 

The recommendation from Dan can only save and not append.

plugin command("File Management.dll""locked save to file"""""),

i dont want to read the file first and then save it, over multiple threads, this is not practicable for me.

 

for the tiny mce usage i did not have found any demo code yet.

 

The other old plugin, with the lock{ function, didnt appear in the plugins.

 

Many thanks, any help much appreciated!  :)

 

This plugin has thread lock and system wide lock. Both will lock it so that only one thread can get in at a time:

 

https://network.ubotstudio.com/forum/index.php/topic/20002-free-heopas-custom-plugin-thread-lock-sqlite-thread-variables-email-ini-clipboard/

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...