Git Product home page Git Product logo

django-grpc's People

Contributors

a-edakin avatar amauryortega avatar buddhiabeyratne avatar dependabot[bot] avatar gluk-w avatar nielsvaneck avatar techunits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

django-grpc's Issues

How to broadcast to stream client

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.

Django apps as grpc clients

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

[Feature Request] Add support for shutdown hook

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:

  1. In the grpc_hook method start a background thread
  2. The server runs
  3. On interrupt, call cleanup code to gracefully shutdown the thread from 1.

Is it possible to support multi process for grpc server

  • Django gRPC version:
  • Django version:
  • Python version:
  • Operating System:

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

how serialize django model to gRPC message?

"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.

Use Python logging module

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?

Django 3 support

  • Django gRPC version: 1.0.6
  • Django version: 3.0.6
  • Python version: 3.7.5
  • Operating System: Ubuntu 18.04

Description

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?

What I Did

Wrote some code that worked, and ran the tests which passed :)

Sometimes all request will no response and hang without error output

  • Django gRPC version: 1.0.8
  • Django version:3.0.8
  • Python version:3.8.5
  • Operating System: Debian GNU/Linux 10 (buster)

Description

Sometimes all request will no response and hang without error output

What I Did

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()

More documentation and steps.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.