I’m running the Google App Engine devserver 1.3.3 on Windows 7.
Usually, this method works fine, but this time it gave an error:
def _deleteType(type):
results = type.all().fetch(1000)
while results:
db.delete(results)
results = type.all().fetch(1000)
The error:
File "src\modelutils.py", line 38, in _deleteType
db.delete(results)
File "C:\Program Files\Google\google_appengine\google\appengine\ext\db\__init__.py", line 1302, in delete
datastore.Delete(keys, rpc=rpc)
File "C:\Program Files\Google\google_appengine\google\appengine\api\datastore.py", line 386, in Delete
'datastore_v3', 'Delete', req, datastore_pb.DeleteResponse(), rpc)
File "C:\Program Files\Google\google_appengine\google\appengine\api\datastore.py", line 186, in _MakeSyncCall
rpc.check_success()
File "C:\Program Files\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 474, in check_success
self.__rpc.CheckSuccess()
File "C:\Program Files\Google\google_appengine\google\appengine\api\apiproxy_rpc.py", line 149, in _WaitImpl
self.request, self.response)
File "C:\Program Files\Google\google_appengine\google\appengine\api\datastore_file_stub.py", line 667, in MakeSyncCall
response)
File "C:\Program Files\Google\google_appengine\google\appengine\api\apiproxy_stub.py", line 80, in MakeSyncCall
method(request, response)
File "C:\Program Files\Google\google_appengine\google\appengine\api\datastore_file_stub.py", line 775, in _Dynamic_Delete
self.__WriteDatastore()
File "C:\Program Files\Google\google_appengine\google\appengine\api\datastore_file_stub.py", line 610, in __WriteDatastore
self.__WritePickled(encoded, self.__datastore_file)
File "C:\Program Files\Google\google_appengine\google\appengine\api\datastore_file_stub.py", line 656, in __WritePickled
os.rename(tmpfile.name, filename)
WindowsError: [Error 183] Cannot create a file when that file already exists
What am I doing wrong? How could this have failed this time, but usually it doesn’t?
UPDATE I restarted the devserver, and when it came back online, the datastore was empty.
Unfortunately, 1.3.3 is too far back for me to look at its sources and try to diagnose your problem precisely – the SDK has no 1.3.3 release tag and I can’t guess which revision of the
datastore_filestub.pywas in 1.3.3. Can you upgrade to the current version, 1.3.5, and try again? Running old versions (especially 2+ versions back) is not recommended since they’ll be possibly a little out of sync with what’s actually available on Google’s actual servers, anyway (and/or have bugs that are fixed in later versions). Anyway…On Windows,
os.renamedoesn’t work if the destination exists — but the revisions I see are careful to catch theOSErrorthat results (WindowsErrorderives from it), remove the existing file, and try renaming again. So I don’t know what could explain your bug — if the sources of the SDK you’re running have that careful arrangement, and I think they do.Plus, I’d recommend to
--use_sqlite(see Nick Johnson’s blog announcing it here) in lieu of the file-stub for your SDK datastore – it just seems to make more sense!-)