Multithreaded work with Google Sheets (Version 7.1.7.0 and higher)

Table of contents


1. ZennoPoster supports multi-threaded work with Google Sheets

This means that one table can be accessed through multiple threads. When executed, all threads will have one instance of a virtual table, changes from which will be periodically synchronized with the table in the cloud.

2. Several copies of ZennoPoster can work with one Google spreadsheet

But it should be borne in mind that changes from the program do not come to the cloud instantly, but within 60 seconds. Therefore, this delay will apply between different copies of ZennoPoster. In this connection, in order to preserve data integrity, it is recommended to use atomic addition of rows, which is included in the settings of a static block.

3. Atomic line addition

When the atomic addition setting is enabled, rows added by the “Add row” action will be sent to the cloud by a special request that does not depend on cell addresses. This will ensure that new data is added to the table without the loss of existing ones caused by overwriting already filled cells.

Please note that in this case, the rows will be sent in a separate query, which will write the data sequentially to the end of the table, which may cause disagreements between the local data view and the data view in the cloud.

For example, with the following sequence of actions, the data added by the “Add line” actions will go to 11 and 12 lines in Google, while being in the 6 and 11 lines in the program:

  1. We wrote the cells in 0-5 lines;

  2. Added a line (6 lines in the program);

  3. We wrote down cells in 7-10 lines;

  4. Added a line (11 lines in the program).

Therefore, when using atomic row addition, it is better to add data only using the “Add line” action.

Although you can safely add lines, modifying or deleting lines can be inconsistent due to latency in synchronization between the copies of the program and the cloud. Therefore, for processing valuable and important data, it is recommended to use a separate sheet of Google Sheets for each copy of the program.

4. How to optimize multi-threaded data writing to one Google spreadsheet

There is a solution for this. For example, if you are parsing some data in batches and adding all the results to one Google table.

ZennoPoster is designed in such a way that it always tries to synchronize the virtual table and the table in the cloud. If there are several copies of ZennoPoster and / or the table has a lot of data, synchronization can take a long time.

In this case, if you do not need up-to-date data from the table in each copy of ZennoPoster, you can configure the fast recording mode via the Edit → Settings → Google spreadsheets → Spreadsheet change processing policy :

In this mode, each copy of the program will only send data, without worrying about matching the table data in the cloud and the data in the program, that is, it will not waste time on this.