16👍
depending on where you want to simulate such you could simply sleep?
from time import sleep
sleep(500)
8👍
On osx or freebds, you can use ipfw
to limit bandwidth on specific ports:
sudo ipfw pipe 1 config bw 1Bytes/s delay 100ms
sudo ipfw add 1 pipe 1 src-port 8000
Do not forget to delete it when you do not need it anymore:
sudo ipfw delete 1
For osx there is also free app that will allow this:
- Zip File downloaded from ReactJs/Axios is corrupted
- Where are the files downloaded using pip stored in virtualenv?
- Session authentication with Django channels
- Registering Django system checks in AppConfig's ready() method
- Django form with fields from two different models
4👍
You could write a customized upload handler or subclass current upload handler to mainly slow down receive_data_chunk()
method in it. Or set a pdb breakpoint inside receive_data_chunk()
and manually proceed the uploading. Or even simpler, try to upload some large file.
- How to assign to a Django PointField model attribute?
- Django order items by two fields, but ignoring them if they're zero
1👍
I’m a big fan of the Charles HTTP Proxy. It lets you throttle the connection and can simulate all sorts of network conditions.
- How to remove the language identifier from django-cms 2.4 URLs?
- Django rest framework nested viewsets and routes
- Django template for loop
- How does a python web server overcomes GIL
1👍
Use the slow file upload handler from django-gubbins:
import time
from django.core.files.uploadhandler import FileUploadHandler
class SlowFileUploadHandler(FileUploadHandler):
"""
This is an implementation of the Django file upload handler which will
sleep between processing chunks in order to simulate a slow upload. This
is intended for development when creating features such as an AJAXy
file upload progress bar, as uploading to a local process is often too
quick.
"""
def receive_data_chunk(self, raw_data, start):
time.sleep(2)
return raw_data
def file_complete(self, file_size):
return None
You can either enable this globally, by adding it to:
FILE_UPLOAD_HANDLERS = (
"myapp.files.SlowFileUploadHandler",
"django.core.files.uploadhandler.MemoryFileUploadHandler",
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
)
Or enable it for a specific request:
request.upload_handlers.insert(0, SlowFileUploadHandler())
Make sure the request is excepted from CSRF checking, as mentioned at https://docs.djangoproject.com/en/dev/topics/http/file-uploads/#id1
1👍
If you want to slow things down across all requests a very easy way to go would be to use ngrok https://ngrok.com/ . Use the ngrok url for requests then connect to a vpn in another country. That will make your requests really slow.
- Returning CSV format from django-rest-framework?
- How to downgrade from Django 1.7 to Django 1.6
- Django bootstrap alerts not working as expected