gluk-w / django-grpc Goto Github PK
View Code? Open in Web Editor NEWEasy gRPC service based on Django application
License: MIT License
Easy gRPC service based on Django application
License: MIT License
Hi, we use stream requests to comminute with django grpc server, but I don't know how server broadcast to clients with connected stream requests.
Very nice project Kudos Stan.
Sorry for the orthogonal question. We have grpc services written in Java and a Django based portal. To communicate with grpc, we end up adding a django rest framework layer to do the marshalling or add Envoy Proxy on server side to expose REST api's. Do you happen to have pointers for us to directly consume grpc messages in a django app with Vue.js front-end? -- Thank you
It would be great to have some kind of shutdown hook, which allows me to run cleanup code, before the server shuts down.
The workflow would be the following:
Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
"There is an easy way to serialize django model to gRPC message using django_grpc.serializers.serialize_model."
i was reading the code trying to understand but i can't, do you have an example code of this?
thanks.
In a couple places in the grpcserver command you have self.stdout.write
which doesn't really play well with customized logging setups. Would it be possible for these to be logging.info()
or logging.debug()
calls instead?
You mentioned to get in touch if you needed Django 3 support. I do! I've tried to get it up and running and... it seems to work (at least with my simple test) and the tests pass. What doesn't work?
Wrote some code that worked, and ran the tests which passed :)
Experts,
Please let me know, if I am going in right direction?
If not provide some examples on using grpc serializers.
Thank you in advance
Sometimes all request will no response and hang without error output
I ran the server with /app/manage.py grpcserver
and there is no output when server gets stuck
but I have added a timer schedule. Does this cause this problem?
def clean_rooms():
clean_logger = logging.getLogger('clean_rooms')
while True:
clean_logger.info('start cleaning rooms')
print('start cleaning rooms')
for key, room_dict in list(rooms.items()):
clean_logger.info(room_dict)
if room_dict.get('is_calling', None):
room_obj = twilio_client.video.rooms(room_dict['room'].sid)
room_instance = room_obj.fetch()
participants = room_obj.participants
room_create_time = room_instance.date_created
if len(participants.list(status='connected')) < 2 and (now() - room_create_time).seconds > 60:
clean_logger.info('room is empty')
room_obj.update(status='completed')
del rooms[key]
call_log: models.TCallLog = models.TCallLog.objects.filter(t_room_id=room_dict['room'].sid).first()
if call_log:
call_log.t_call_time = (now() - call_log.t_create_time).seconds
call_log.save()
else:
if room_dict.get('update_at', None) and room_dict.get('update_at') + timedelta(seconds=10) < now():
clean_logger.info('room is timeout')
# 更新超时
del rooms[key]
if room_dict.get('start_at') + timedelta(seconds=60) < now():
clean_logger.info('room is timeout')
# 更新超时
del rooms[key]
time.sleep(5)
def update_room(key, room_dict):
rooms[key] = room_dict
def task_list():
clean_process = multiprocessing.Process(target=clean_rooms,)
clean_process.start()
# num_cores = int(multiprocessing.cpu_count())
# logger.info("本地计算机有: " + str(num_cores) + " 核心")
# pool = multiprocessing.Pool(num_cores)
# pool.apply_async(clean_rooms)
# logger.info('start to clean rooms')
# try:
# clean_rooms()
# except Exception as e:
# traceback.print_exc()
# sTimer = Timer(5, task_list)
# sTimer.start()
task_list()
Latest package is not updated on pip as --autoreload
is not working for django 2.2
Can you provide a complete django view code?
Hi,
Is there way you can provide step by step guides in your README on how to create and integrate an GRPC server into Django.
The README doesn't have enough information to setup things.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.