Skip to content

Commit d267a4e

Browse files
committed
Use random available ports in server examples
Otherwise parallel doc tests may fail with "Address already in use".
1 parent bdba484 commit d267a4e

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

puffin_http/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
//! When the server is started, [`puffin_viewer`](https://crates.io/crates/puffin_viewer) application can connect to it and display profiling information.
66
//!
77
//! ```
8-
//! let server_addr = format!("127.0.0.1:{}", puffin_http::DEFAULT_PORT);
9-
//! let _puffin_server = puffin_http::Server::new(&server_addr).unwrap();
10-
//! eprintln!("Serving demo profile data on {server_addr}. Run `puffin_viewer` to view it.");
8+
//! let puffin_server = puffin_http::Server::new("127.0.0.1:0").unwrap();
9+
//! let addr = puffin_server.local_addr();
10+
//! eprintln!("Serving demo profile data on {}. Run `puffin_viewer --url \"{}\"` to view it.", addr, addr);
1111
//! puffin::set_scopes_on(true);
1212
//! ```
1313

puffin_http/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl Server {
8989
/// #
9090
/// #
9191
/// // Initialise the profiling server for the main app
92-
/// let default_server = Server::new("localhost:8585").expect("failed to create default profiling server");
92+
/// let default_server = Server::new("localhost:0").expect("failed to create default profiling server");
9393
/// puffin::profile_scope!("main_scope");
9494
///
9595
/// // Create a new [GlobalProfiler] instance. This is where we will be sending the events to for our threads.

0 commit comments

Comments
 (0)