Andrey Polkanov
Andrey Polkanov

Reputation: 1

Folders created with Python code from 2 Colab accounts in one Google Drive shared folder in a small time period unexpectedly have the same names

There’s a Google Drive shared folder shared_folder where 2 different accounts can create folders with Python code run in Jupyter notebooks on Colab.

If one of these accounts try to create 2 duplicated folders, he will get an error:

import os
os.mkdir('/content/drive/MyDrive/shared_folder/test_folder')
os.mkdir('/content/drive/MyDrive/shared_folder/test_folder')

FileExistsError: [Errno 17] File exists: '/content/drive/MyDrive/shared_folder/test_folder'

But if those both accounts try to create the same named folder in a small period time in between - there's no any error and the behaviour is more than strange:

  1. In GDrive there're 2 folders with the same name
  2. In Colab Files pane there're 2 folders with different names

'/content/drive/MyDrive/shared_folder/test_folder' and '/content/drive/MyDrive/shared_folder/test_folder (1)'

  1. I added marker files first.txt and second.txt into these folders and checked them under both accounts. So there's no consistency of postfix (1) appearing as we can see first.txt in both test_folder and test_folder (1) under different accounts: acc 1, acc 2

I'm looking for a solution which could provide me with consistent behaviour such as was described in the beginning when I got an error trying to create duplicated folder, but this time suitable for creating duplicates under 2 different accounts. In other words, I need to safely create folders in the same place under 2 different accounts.

As I understand, the issue is that GDrive has some lag in updating the second account with the information from the first one created something seconds before.

How would you solve this issue? Any thoughts?

Upvotes: 0

Views: 169

Answers (0)

Related Questions