Coder Social home page Coder Social logo

cpo_lab3's Introduction

cpo_lab3

Computational Process Organization lab3

title: Futures with worker pool

list of group members

laboratory work number: 4

variant description

In this variant, we implement a futures library . For that, we use done , cancel, result, submit, map methods to run.

synopsis

work of Zhao Ji &Duan Shoujian :

  1. implement the following API:
    • IsDone() – return True if future evaluation is complete;
    • InProgress() – return True if future evaluated right now;
    • Result(timeout=None) return the future execution result (if the future is done); raise the exception (if the future is done and raise an exception); block until future is done (if the timeout is None and future is not done); raise TimeoutError after timeout (if the timeout is not None and the future is not done).
    • map(List, Function) and reduce(List, Function, Initial State).
    • Cancel() – cancel a future (if the future not executed).
  2. To proof correctness, we write unit tests, properties-based tests.

descriptions of modules

in the module of futures:

  • def cancel(self):
  • def result(self, timeout=None):
  • def running(self):
  • def exception(self, timeout=None):
  • def submit(self, fn, *args, **kwargs):
  • def shutdown(self, wait=True):

conclusion

The Python Futures module, located in concurrent.futures and asyncio, both represent operations with delays. Futures will wrap the operations in the waiting state and put them in the queue. The status of these operations can be queried at any time. Of course, their results (or exceptions) can also be obtained after the operation is completed. Using futures in some ways can greatly reduce time

cpo_lab3's People

Contributors

duanshoujian avatar 1986081114 avatar

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.