Skip to content

Commit 8497042

Browse files
committed
Switch to Python 3.12
1 parent 1454b69 commit 8497042

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

_labs/concurrent-http-server.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Use the GitHub Classroom link posted in the Teams channel for the lab to accept
2020

2121
For this lab, you will be extending your HTTP server to handle multiple clients _at once_. The rest of your server will stay the same. There are multiple ways of supporting multiple clients. A typical approach is to spawn a new thread or process for each client that connects. That thread or process is responsible for communicating with a specific client. There is another approach that uses a system call (`poll` or `select`) to determine which sockets are ready to receive data from or write data to. Since with socket programming, most of the time your program is waiting around for the sockets to send or receive data, this allows your program to handle multiple sockets at once. Instead of creating a new thread or process for each client socket, one process keeps track of many sockets at once.
2222

23-
For this lab, you are required to implement a concurrent server in three ways: using threads, using a thread pool, and using `select`. Using standard threads, when a new request comes in, a thread is created and the socket is passed to that thread. The newly spawned thread is now responsible for receiving and sending data while the main thread is still accepting new clients. With a thread pool, you create a bunch of threads before starting your server and hand tasks (i.e., new clients) to threads that are idle. As mentioned in lecture, threads have their own set of issues, largely shared memory. To limit these issues, try to use local variables as much as possible. You should not need to use mutex/locks in this lab! For the `select` implementation, you will need to use the [`select` call](https://docs.python.org/3/library/selectors.html) to determine which sockets are ready to read from or write to. This is a more advanced technique and requires a good understanding of how sockets work. You will need to maintain a list of all the client sockets that are connected to your server and use `select` to determine which sockets are ready for reading or writing.
23+
For this lab, you are required to implement a concurrent server in three ways: using threads, using a thread pool, and using `select`. Using standard threads, when a new request comes in, a thread is created and the socket is passed to that thread. The newly spawned thread is now responsible for receiving and sending data while the main thread is still accepting new clients. With a thread pool, you create a bunch of threads before starting your server and hand tasks (i.e., new clients) to threads that are idle. As mentioned in lecture, threads have their own set of issues, largely shared memory. To limit these issues, try to use local variables as much as possible. You should not need to use mutex/locks in this lab! For the `select` implementation, you will need to use the [`select` call](https://docs.python.org/3.12/library/selectors.html) to determine which sockets are ready to read from or write to. This is a more advanced technique and requires a good understanding of how sockets work. You will need to maintain a list of all the client sockets that are connected to your server and use `select` to determine which sockets are ready for reading or writing.
2424

2525
As part of writing a well behaving server, you will need to appropriately handle the threads when you are exiting (the user hits `ctrl-c`). This allows your server to finishing handling clients that have already connected before shutting down the server. To do this, you must join all spawned threads.
2626

@@ -65,13 +65,13 @@ Run the benchmark **3 or more times** and report the best run. You should turn o
6565

6666
## Requirements
6767

68-
- You must use Python 3.10 for this lab.
68+
- You must use Python 3.12 for this lab.
6969

7070
- The name of your program must be named `http_server.py`.
7171

7272
- You must be able to handle multiple concurrent clients at once using threads and a thread pool.
7373

74-
- You can only use the low-level [threading.Thread](https://docs.python.org/3/library/threading.html#thread-objects) objects. All high-level concurrency libraries like [concurrent.futures](https://docs.python.org/3/library/concurrent.futures.html) is not allowed. Python has implementations of thread pools, but you must implement these yourself to get the credit.
74+
- You can only use the low-level [threading.Thread](https://docs.python.org/3.12/library/threading.html#thread-objects) objects. All high-level concurrency libraries like [concurrent.futures](https://docs.python.org/3.12/library/concurrent.futures.html) is not allowed. Python has implementations of thread pools, but you must implement these yourself to get the credit.
7575

7676
- Add the `-c`/`--concurrency` flags to your program. If the concurrency flag is not provided, the default value should be `thread`.
7777

@@ -98,8 +98,8 @@ To submit your code, upload it to Gradescope.
9898

9999
## Resources
100100

101-
- [Python Threads](https://docs.python.org/3/library/threading.html)
101+
- [Python Threads](https://docs.python.org/3.12/library/threading.html)
102102

103103
- [Python Queue (good for coordinating between threads)](https://docs.python.org/3.10/library/queue.html)
104104

105-
- [Python Select](https://docs.python.org/3/library/selectors.html)
105+
- [Python Select](https://docs.python.org/3.12/library/selectors.html)

_labs/http-server.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ Then all requests would be relative to the `www` folder. The previous request wo
4848

4949
## Requirements
5050

51-
- You must use Python 3.10 for this lab.
51+
- You must use Python 3.12 for this lab.
5252

5353
- You **can not use any third party Python libraries** for this lab. If you have to `pip install` or clone any repos, in order to import a library, stop. The only exception is the formatter, [Black](https://github.com/psf/black), which you have to `pip install`. However, you do not use it in your code.
5454

55-
- For all socket related tasks, you must only use the [low-level `socket` interface](https://docs.python.org/3/library/socket.html) that Python provides. No high-level server socket interfaces are allowed.
55+
- For all socket related tasks, you must only use the [low-level `socket` interface](https://docs.python.org/3.12/library/socket.html) that Python provides. No high-level server socket interfaces are allowed.
5656

5757
- The name of your program must be named `http_server.py`.
5858

_labs/nibbletorrent-peer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Here is a diagram showing the general interactions between the different compone
246246

247247
## Requirements
248248

249-
- You must use Python 3.10 for this lab.
249+
- You must use Python 3.12 for this lab.
250250

251251
- The only third-party Python library you are allowed to use in this lab is [requests](https://requests.readthedocs.io/en/latest/). That way you don't have to write your own HTTP client. All other third-party libraries are off limits.
252252

@@ -304,8 +304,8 @@ To demonstrate this, follow these steps:
304304

305305
- [How to get your private IP address](https://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib/)
306306

307-
- [Parsing JSON in Python](https://docs.python.org/3/library/json.html)
307+
- [Parsing JSON in Python](https://docs.python.org/3.12/library/json.html)
308308

309-
- [Good way of creating a TCP server in Python](https://docs.python.org/3/library/socketserver.html)
309+
- [Good way of creating a TCP server in Python](https://docs.python.org/3.12/library/socketserver.html)
310310

311311
- [Converting hex strings to bytes](https://stackoverflow.com/questions/5649407/how-to-convert-hexadecimal-string-to-bytes-in-python)

_labs/simple-tls.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ optional arguments:
137137

138138
## Requirements
139139

140-
- You must use Python 3.10 for this lab.
140+
- You must use Python 3.12 for this lab.
141141

142142
- The only third-party Python library you are allowed to use in this lab is [cryptography](https://cryptography.io/en/latest/), and the two modules I am providing, `crypto_utils.py`, and `message.py`. You shouldn't have to use the cryptography library directly if you plan on using `crypto_utils.py` All other third-party libraries are off limits.
143143

@@ -167,7 +167,7 @@ To submit your code, upload it to Gradescope.
167167

168168
- Generating a cryptographic nonce
169169
- [Question](https://stackoverflow.com/questions/5590170/what-is-the-standard-method-for-generating-a-nonce-in-python)
170-
- [`secrets.token_bytes`](https://docs.python.org/3/library/secrets.html#secrets.token_bytes)
170+
- [`secrets.token_bytes`](https://docs.python.org/3.12/library/secrets.html#secrets.token_bytes)
171171

172172
- [Convert integer to bytes](https://www.geeksforgeeks.org/how-to-convert-int-to-bytes-in-python/)
173173

_labs/tcp-server.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Your server will be designed to block forever. Once it has handled one client, i
7070

7171
### Logging
7272

73-
Like the previous labs, I strongly encourage you to use logging to help debug your program and understand its flow. Python provides a powerful [logging library](https://docs.python.org/3/howto/logging.html). Spend some time learning it and it will pay off later.
73+
Like the previous labs, I strongly encourage you to use logging to help debug your program and understand its flow. Python provides a powerful [logging library](https://docs.python.org/3.12/howto/logging.html). Spend some time learning it and it will pay off later.
7474

7575

7676
## Objectives
@@ -82,11 +82,11 @@ Like the previous labs, I strongly encourage you to use logging to help debug yo
8282

8383
## Requirements
8484

85-
- You must use Python 3.10 for this lab (and all other Python labs).
85+
- You must use Python 3.12 for this lab (and all other Python labs).
8686

8787
- You **can not use any third party Python libraries** for this lab. If you have to `pip install` or clone any repos, in order to import a library, stop. The only exception is the formatter, [Black](https://github.com/psf/black), which you have to `pip install`. However, you do not use it in your code.
8888

89-
- For all socket related tasks, you must only use the [low-level `socket` interface](https://docs.python.org/3/library/socket.html) that Python provides. No high-level server socket interfaces are allowed.
89+
- For all socket related tasks, you must only use the [low-level `socket` interface](https://docs.python.org/3.12/library/socket.html) that Python provides. No high-level server socket interfaces are allowed.
9090

9191
- The name of your program must be named `tcp_server.py`.
9292

@@ -130,14 +130,14 @@ To submit your code, upload it to Gradescope.
130130

131131
## Resources
132132

133-
- [socket — Low-level networking interface](https://docs.python.org/3/library/socket.html). Make sure to look at all of the functions available to you.
133+
- [socket — Low-level networking interface](https://docs.python.org/3.12/library/socket.html). Make sure to look at all of the functions available to you.
134134

135-
- [argparse](https://docs.python.org/3/library/argparse.html).
135+
- [argparse](https://docs.python.org/3.12/library/argparse.html).
136136

137-
- [Packing and unpacking binary data in Python](https://docs.python.org/3/library/struct.html).
137+
- [Packing and unpacking binary data in Python](https://docs.python.org/3.12/library/struct.html).
138138

139-
- [Convert an integer into binary](https://docs.python.org/3/library/stdtypes.html#int.to_bytes).
139+
- [Convert an integer into binary](https://docs.python.org/3.12/library/stdtypes.html#int.to_bytes).
140140

141-
- [random](https://docs.python.org/3/library/random.html).
141+
- [random](https://docs.python.org/3.12/library/random.html).
142142

143-
- [Logging HOWTO](https://docs.python.org/3/howto/logging.html) and the [Logging interface](https://docs.python.org/3/library/logging.html).
143+
- [Logging HOWTO](https://docs.python.org/3.12/howto/logging.html) and the [Logging interface](https://docs.python.org/3.12/library/logging.html).

_pages/coding_standard.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ icon: fas fa-terminal
4242
## Python Coding Standard
4343

4444
### 1. General
45-
* **1.1** You must use Python 3.10
45+
* **1.1** You must use Python 3.12
4646

4747
* **1.2** Your code, when submitted, must be in a finished form. You must not have any commented out lines of code.
4848

0 commit comments

Comments
 (0)