TAILIEUCHUNG - Beginning PythonFrom Novice to Professional, Second Edition 2008 phần 9

XML-RPC. (Điều này là một phần của hành vi của SimpleXMLRPCServer, không phải là một phần của XML-RPC bản thân.) Đó là hữu ích bởi vì những phương pháp này không có nghĩa là để cung cấp chức năng riêng biệt cho bên ngoài, nhưng có cấu trúc mã. | 522 CHAPTER 27 PROJECT 8 FILE SHARING WITH XML-RPC XML-RPC. This is part of the behavior of SimpleXMLRPCServer not a part of XML-RPC itself. That is useful because these methods aren t meant to provide separate functionality to an outside party but are there to structure the code. For now let s just assume that _handle takes care of the internal handling of a query checks whether the file exists at this specific Node fetches the data and so forth and that it returns a code and some data just as query itself is supposed to. As you can see from the listing if code OK then code data is returned immediately the file was found. However what should query do if the code returned from _handle is FAIL Then it must ask all other known Nodes for help. The first step in this process is to add to history. Note Neither the operator nor the append list method has been used when updating the history because both of these modify lists in place and you don t want to modify the default value itself. If the new history is too long query returns FAIL along with an empty string . The maximum length is arbitrarily set to 6 and kept in the global constant MAX_HISTORY_LENGTH. WHY IS MAX_HISTORY_LENGTH SET TO 6 The idea is that any peer in the network should be able to reach another in at most six steps. This of course depends on the structure of the network which peers know which but is supported by the hypothesis of six degrees of separation which applies to people and who they know. For a description of this hypothesis see for example Wikipedia s article on six degrees of separation http wiki Six_degrees_of_separation . Using this number in your program may not be very scientific but at least it seems like a good guess. On the other hand in a large network with many nodes the sequential nature of your program may lead to bad performance for large values of MAX_HISTORY_LENGTH so you might want to reduce it if things get slow. If history isn t too long the next .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.