When some_file.open() is called, is the info returned immediately available?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JoaoCesar
:warning: Old Version Published before Godot 3 was released.

When some_file.open and some_file.close are used, the info is immediately available to be used (synchronously?) in the same “tic”? In the attached image, will answers_dict always have some data in it?

Examgple

:bust_in_silhouette: Reply From: Zylann

When you read a file in GDScript, it happens synchronously, there are no threads involved on your side. You can use the data after it is read.

I don’t see where you set the singleton.questions_file variable, but I guess if you fill it with the results of read() before calling questions(), it will contain what you want.

Thank you a lot!!!

I really needed to know the exact behavior because I had a problem that only happened a few times so one of my thoughts was that probably singleton.read() was returning nothing from time to time.

And, yes, the singleton.questions_file is already set when I call singleton.read().

Regards,
JC

JoaoCesar | 2016-11-10 10:43