-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Labels
🚨This issue needs some love.This issue needs some love.api: firestoreIssues related to the googleapis/python-firestore API.Issues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Originally reported here: firebase/firebase-admin-python#548
If firebase_admin is imported before os.fork(), auto-generated document IDs are repeated causing data to be overwritten.
Environment details
- OS type and version: Linux Mint 20
- Python version: Python 3.6.13
- pip version: pip 21.1
google-cloud-firestoreversion: 2.1.0
Steps to reproduce
Import firebase_admin, fork, create firestore client, write a new document.
Code example
#!/usr/bin/env python3.6
import os
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
pid = os.fork()
cred = credentials.Certificate('service_account.json')
firebase_admin.initialize_app(cred)
client = firestore.client()
if pid == 0:
reference = client.collection('Test').document()
reference.set({'a': 'b'})
print('Child: ' + reference.id)
else:
reference = client.collection('Test').document()
reference.set({'a': 'c'})
print('Parent: ' + reference.id)Output:
Child: TCsit2S0VQgvqm0aHNTc
Parent: TCsit2S0VQgvqm0aHNTc
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: firestoreIssues related to the googleapis/python-firestore API.Issues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.